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
38
39
40
41
42
43
44
45
46
// Bartlomiej Stefanski
#include <iostream>

using namespace std;

#define FORD(x, b, e) for (int x = b; x >= (e); --x)
#define REP(x, n) for (int x = 0; x < (n); ++x)

int n, k;
int temp;
int ans = 0;
int oceny[121];

int main()
{
    // FAST IO
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k;

    REP(i, 121)
    {
        oceny[i] = 0;
    }

    REP(i, n)
    {
        cin >> temp;
        oceny[temp]++;
    }

    // znajdz koszt
    FORD(i, 120, 1) if (k > 0)
    {
        ans += oceny[i];
        k -= oceny[i];
    }

    cout << ans;
}

/*
5 3
75 90 120 75 40
*/