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>
#include <vector>
using namespace std;
int main()
{
    int num_of_participants, num_of_shirts;
    cin >> num_of_participants >> num_of_shirts;
    int number = num_of_shirts;
    vector<int> scores = {};
    for (int i = 0; i < num_of_participants; i++)
    {
        int score;
        cin >> score;
        scores.push_back(score);
    }
    scores.shrink_to_fit();
    sort(scores.begin(), scores.end(), std::greater<int>());
    for (int i = num_of_shirts - 1; i < num_of_participants - 1; i++)
    {
        if (scores[i] != scores[i + 1])
            break;
        number++;
    }
    cout << number;
    return 0;
}