1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <algorithm>
using namespace std;
int tab[2010];
bool comp(int a, int b) {
    return a > b;
}
int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> tab[i];
    }
    sort(tab + 1, tab + n + 1, comp);
    int ile = k;
    for (int i = k + 1; i <= n; i++) {
        if (tab[i] == tab[k]) {
            ile++;
        }
    }
    cout << ile;
}