#include<bits/stdc++.h>
using namespace std;
map<int,int>punkty;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
long long n,m;
cin>>n>>m;
for(int i=0;i<n;i++)
{
int x;
cin>>x;
punkty[x]++;
}
long long shirts=0;
for (map<int,int>::iterator it=punkty.end();1==1; --it)
{
if(m<=shirts)
{
cout<<shirts;
return 0;
}
shirts+=it->second;
}
}
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 | #include<bits/stdc++.h> using namespace std; map<int,int>punkty; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n,m; cin>>n>>m; for(int i=0;i<n;i++) { int x; cin>>x; punkty[x]++; } long long shirts=0; for (map<int,int>::iterator it=punkty.end();1==1; --it) { if(m<=shirts) { cout<<shirts; return 0; } shirts+=it->second; } } |
English