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
35
36
37
38
39
#include <bits/stdc++.h>
using namespace std;

//zmienne
int n, k;

//kontenery
vector <int> points;

//funkcje
//**********************************

//**********************************

int main()
{
  scanf("%i %i", &n, &k);

  int p;
  for (int i = 0; i < n; i++)
  {
    scanf("%i", &p);
    points.push_back(p);
  }

  sort(points.begin(), points.end());

  int i = n-k-1;
  int c = k;
  while(points[i] == points[n-k] && i >= 0)
  {
    c++;
    i--;
  }

  printf("%i", c);

return 0;
}