#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef LOCAL
#define debug(...) __VA_ARGS__
#else
#define debug(...) {}
#endif
int ile[121];
int main(){
ios_base::sync_with_stdio(0);
cin.tie();
cout.tie();
int i;
int n,m;
cin>>n>>m;
for (i = 0; i < n ; i++){
int x;
cin>>x;
ile[x]++;
}
int wy = 0;
for (i = 120; i > -1; i--){
wy += ile[i];
m -= ile[i];
if (m <= 0) break;
}
cout<<wy<<"\n";
return 0;
}
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 | #include <bits/stdc++.h> using namespace std; typedef long long ll; #ifdef LOCAL #define debug(...) __VA_ARGS__ #else #define debug(...) {} #endif int ile[121]; int main(){ ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); int i; int n,m; cin>>n>>m; for (i = 0; i < n ; i++){ int x; cin>>x; ile[x]++; } int wy = 0; for (i = 120; i > -1; i--){ wy += ile[i]; m -= ile[i]; if (m <= 0) break; } cout<<wy<<"\n"; return 0; } |
English