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<bits/stdc++.h>
using namespace std;

const int maxn = 2000;
int tab[maxn];
int n, k, res, a;

int main()
{
    cin >> n >> k;
    for(int i = 0; i < n; ++i)
    {
        cin >> tab[i];
    }
    sort(tab, tab+n); reverse(tab, tab+n);
    res = k;
    a = tab[k-1];
    for(int i = k; i < n; ++i)
    {
        if(a == tab[i])
        {
            res++; a = tab[i];
        }
        else break;
    }
    cout << res;
    return 0;
}