#include<iostream>
using namespace std;
int n, k, tab[121], a, t;
int main()
{
ios_base::sync_with_stdio(false);
cin>>n>>k;
for(int j=0; j<n; j++)
{
cin>>a;
tab[a]++;
}
int j=120;
while(t<k)
{
t=t+tab[j];
j--;
}
cout<<t;
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 | #include<iostream> using namespace std; int n, k, tab[121], a, t; int main() { ios_base::sync_with_stdio(false); cin>>n>>k; for(int j=0; j<n; j++) { cin>>a; tab[a]++; } int j=120; while(t<k) { t=t+tab[j]; j--; } cout<<t; return 0; } |
English