1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <cstdio>
#define MAX_A 200

int buckets[MAX_A];

int main() {
    int n, k, x;
    int ile = 0;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &x);
        buckets[x]++;
    }

    for (int i = MAX_A - 1; i >= 0 ; i--) {
        ile += buckets[i];
        if (ile >= k) {
            break;
        }
    }

    printf("%d\n", ile);
}