1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <algorithm>
#include <cstdio>
#include <vector>

int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    std::vector<int> points(n);
    for (int i=0; i<n; ++i) {
        scanf("%d", &points[i]);
    }
    std::sort(points.begin(), points.end(), std::greater<int>());
    const int p = points[k-1];
    while (k<n && points[k]==p) {
        ++k;
    }
    printf("%d\n", k);
}