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
//Mateusz Piórkowski
#include <iostream>
#include <set>

int main(){
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::multiset<int, std::greater<int>> uczestnicy;
	int n,k;
	std::cin >> n >> k;
	for(int i=0; i<n; i++){
		int points;
		std::cin >> points;
		uczestnicy.insert(points);
	}
	int pos=0;
	int prev=0;
	int add_shirts=0;
	for(int points : uczestnicy){
		//std::cout << points << "\n";
		pos+=1;
		//std::cout << "prev:" << prev << "\n";
		if(pos <= k){
			//std::cout << ">";
			prev=points;
		}else{
			if(points == prev) add_shirts+=1;
		}
	}
	std::cout << k + add_shirts << "\n";
}