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
32
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

vector<int> d;

int main(){
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++){
		int a;
		cin >> a;
		d.push_back(a);
	}
	sort(d.begin(), d.end(), greater<int>());
	if (k == n){
		cout << k << "\n";
		return 0;
	}
	int p = k - 1;
	int score = d[k - 1];
	for (int i = k; i < n; i++){
		if (d[i] == score){
			p++;
		}
	}
	cout << p + 1 << "\n";
	return 0;


}