1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <bits/stdc++.h>
int arr[2005];
int main(){
    int n,k;
    std::cin>>n>>k;
    for (int i=0; i<n; i++){
        std::cin>>arr[i];
    }
    
    std::sort(arr, arr+n, std::greater<int>());
    arr[n]=-100;
    int i=0;
    do{
        i++;
    }while (i<k||arr[i-1]==arr[i]);
    std::cout<<i;
}