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
#include <iostream>
#include <cstdint>
#include <array>

using namespace std;

uint16_t koszulki()
{
    array<uint16_t, 120> data = {};

    uint16_t k, n, val;

    cin >> k >> n;

    for (size_t i = 0; i < k; i++)
    {
        cin >> val;
        data[val-1] += 1;
    }

    uint16_t sum = 0;

    for (size_t i = 120; i > 0; i--)
    {
        sum += data[i - 1];
        if (sum >= n) {
            break;
        }
    }
    return sum;
}

int main() {
    cout << koszulki();
    return 0;
}