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
//by KR koszulki [kos] c
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int n, k;
	vector <int> a;
	cin >> n >> k;
	int wynik = k;
	for (int i = 0; i < n; i++)
	{
		int p;
		cin >> p;
		a.push_back(p);
	}
	sort(a.begin(), a.end());
	if (n != k) 
	{
		for (int i = n - k; a[i] == a[i - 1]; i--)
		{
			wynik++;
		}
	}

	cout << wynik;
	return 0;
}