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
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
bool c1(int a, int b){return a>b;}
int main(){
    int n,k;
    cin >> n >> k;
    vector<int>w(n);
    for (int i=0;i<n;i++){
        cin >> w[i];
    }
    sort(w.begin(),w.end(),c1);
    /*for (int i=0;i<n;i++){cout << w[i] << " ";}
    cout << endl;*/
    /*auto i=upper_bound(w.begin(),w.end(),w[k-1])-1;
    cout << i-w.begin() << endl;*/
    /*if(k>=n){cout << n << endl; return 0;}
    int i=k;*/
    int s=w[k-1];
    int i=k;
    int odp=k;
    while(w[i]==s && i<n){
        i++;
        odp++;
    }
    cout << odp << endl;
    return 0;
}