1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

int main() {
    int N,K;
    std::vector<int> scores;

    scanf("%d %d", &N, &K);

    for (int i=0; i<N; ++i) {
        int x;
        scanf("%d", &x);
        scores.push_back(x);
    }

    std::sort(scores.begin(), scores.end(), std::greater<int>());

    int pos = K;
    while (pos < N && scores[pos] == scores[pos-1]) {
        pos++;
    }

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