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
//  Created by Michal Kowalski on 07/12/2021.
//
#include <iostream>
#include <algorithm>
#include <vector>

int N,K;

bool sort_int (int i,int j) { return (i>j); }

int main() {
    scanf("%d %d",&N,&K);
    std::vector<int> V;
    V.reserve(N);
    for (int i=0;i<N;++i) {
        int j = 0;
        scanf("%d",&j);
        V.push_back(j);
    };
    std::sort(V.begin(),V.end(), sort_int);
    std::vector<int>::iterator it = V.begin() + K - 1;
    int p = *it;
    int k = K;
    ++it;
    while (p == *it && it != V.end()) {
        ++k;
        ++it;
    }
    printf("%d\n",k);
    return 0;
}