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 <algorithm>
using namespace std;

int k, n;
int tab[2001];

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

  cin >> n >> k;
  for (int i=0; i<n; i++)
    cin >> tab[i];

  sort(tab, tab+n, greater<int>());
  tab[n] = 0; // make sure that there is someone without t-shirt
  
  int ans = k;
  int last_result = tab[ans - 1];
  while (tab[ans] == last_result) // check if next person should be included
    ans++;

  cout << ans;

  return 0;
}