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
29
30
31
32
33
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int results[2000];
    int coders, prices;

    cin >> coders >> prices;

    int answer = prices;

    for(int i = 0; i < coders; i++) {
        cin >> results[i];
    }

    sort(results, results + coders, greater<int>());
//    for(int i = 0; i < coders; i++) {
//        cout << "res[" << i << "]: " << results[i] << ", ";
//    }

    int current = prices;
    int last = results[prices - 1];
    while(current < coders && results[current] == last) {
       current++;
       answer++;
    }

    cout << answer << "\n";
}