Friday, April 18, 2014

Codeforces Coder-Strike 2014 - Round 1 Problem B - Network Configuration solution

Codeforces Coder-Strike 2014 - Round 1 Problem B - Network Configuration: http://codeforces.com/contest/412/problem/B

Codeforces Coder-Strike 2014 - Round 1 Problem B - Network Configuration solution:


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int a[33000];

int main() {
    int n, k, b;
    memset(a, 0, sizeof(a));
    scanf("%d%d", &n, &k);
    while(n--) scanf("%d", &b), a[b]++;
    for(int i=32770; i>=0; i--) {
        k-=a[i]; 
        if(k<=0) {printf("%d", i); break;}
    }
    return 0;
}

No comments:

Post a Comment