#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int t[121];
int d[2001];
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(false);
int n, k, i, j, w=0;
string c;
cin>>n>>k;
for(i=0; i<n; i++) cin>>d[i];
for(i=0; i<n; i++)
{
for(j=0; j<121; j++)
{
if(d[i]==j) t[j]++;
}
}
for(i=120; i>=0; i--)
{
if(w<k) w=w+t[i];
}
cout<<w;
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 31 32 33 34 35 36 37 38 | #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int t[121]; int d[2001]; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int n, k, i, j, w=0; string c; cin>>n>>k; for(i=0; i<n; i++) cin>>d[i]; for(i=0; i<n; i++) { for(j=0; j<121; j++) { if(d[i]==j) t[j]++; } } for(i=120; i>=0; i--) { if(w<k) w=w+t[i]; } cout<<w; return 0; } |
English