1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include "bits/stdc++.h" // Ignacy Boehlke
using namespace std;     // XIII LO Szczecin

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> sc(n);
    for (int& s : sc) scanf("%d", &s);
    sort(sc.rbegin(), sc.rend());
    int i = --k;
    for (; i < n && sc[i] == sc[k]; ++i) {}
    printf("%d\n", i);
}