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<bits/stdc++.h>
using namespace std;

int tab[125];

int main()
{
    int n,pkt;
    cin >> n >> pkt;
    for(int i=0; i<n; i++)
    {
        int x;
        cin >> x;
        tab[x]++;
    }
    int w=0;
    for(int i=120; i>=0; i--)
    {
        w+=tab[i];
        pkt-=tab[i];
        if(pkt<=0)
        {
            break;
        }
    }
    cout << w;
}