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
27
28
#include <iostream>
#include <queue>

using namespace std;

int main() {
    int k, n, points;
    cin>>n;
    cin>>k;
    
    priority_queue<int> pq;
    for (int i = 0; i < n; i++) {
        cin>>points;
        pq.push(points);
    }
    int i = 0, prevPoints, currPoints=-1;
    do {
        prevPoints = currPoints;
        currPoints = pq.top();
        pq.pop();
        if (i >= k && prevPoints != currPoints) {
            break;
        }
        i++;
    } while(!pq.empty());
    cout<<i<<endl;
    return 0;
}