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
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>

int main()
{
	int n, k, a;
	scanf("%d %d", &n, &k);
	std::vector<int> scores;
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a);
		scores.push_back(a);
	}
	std::sort(scores.begin(), scores.end(), std::greater<int>());
	int draws{0};
	auto it = scores.begin() + k;
	while (it != scores.end() && *it == scores[k - 1])
	{
		it++;
		draws++;
	}
	printf("%d\n", k + draws);
	return 0;
}