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
33
34
//runda 1C
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);

  int n, k, p, wynik;
  vector<int> rank;

  cin >> n >> k;
  rank.reserve(n);
  for(int iN = 0; iN < n; ++iN) {
    cin >> p;
    rank.push_back(p);
  }
  sort(rank.begin(), rank.end(), std::greater<int>());
  wynik = k;
  if(k == n) {
	  cout << wynik;
	  return 0;
  }
  for(int iN = k; iN < n; ++iN) {
	  if(rank[iN] == rank[iN - 1])
		  ++wynik;
	  else
		  break;
  }
  cout << wynik;
  return 0;
}