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
#include <bits/stdc++.h>

using namespace std;

struct TestCase
{
  size_t score_count, min_best_count;
  vector<size_t> scores;
};

TestCase read_test_case();
void solve_test_case(const TestCase&);

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve_test_case(read_test_case());
}

TestCase read_test_case()
{
  TestCase tc;
  cin >> tc.score_count >> tc.min_best_count;
  tc.scores.resize(tc.score_count);
  for (auto& score : tc.scores) cin >> score;
  sort(tc.scores.begin(), tc.scores.end(), greater<int>());
  return tc;
}

void solve_test_case(const TestCase& tc)
{
  size_t result = 0;
  for (auto score : tc.scores)
    if (score >= tc.scores[tc.min_best_count - 1]) result++;
  cout << result << "\n";
}