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
#include <iostream>
#include <vector>
#include <algorithm>


int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	std::vector<int> scores;
	for (int i = 0; i < n; i++)
	{
		int score;
		scanf("%d", &score);
		scores.push_back(score);
	}
	std::sort(scores.begin(), scores.end(), std::greater<int>());
	int result = k;
	for (int i = k; i < n; i++)
	{
		if (scores[i] == scores[k - 1])
			result++;
		else
			break;
	}
	printf("%d\n", result);
}