1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int players, shirts;
    std::cin >> players >> shirts;
    std::vector<int> scores;
    scores.reserve(players);
    for (int i = 0; i < players; ++i)
    {
        int score;
        std::cin >> score;
        scores.push_back(score);
    }
    std::sort(scores.begin(), scores.end(), std::greater<int>());
    int count = shirts;
    for (; count<players; ++count)
        if (scores[count-1] != scores[count])
            break;
    std::cout << count << std::endl;
    return 0;
}