#include <bits/stdc++.h>
using namespace std;
int tab[2005];
bool porownaj (int a, int b)
{return a>b;
}
int main()
{ ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n,k,i,w=0;
cin>>n>>k;
for (i=0;i<n;i++) cin>>tab[i];
if (n<=k)cout<<n;
else
{ sort(tab,tab+n,porownaj);
i=k; w=k;
while(tab[i]==tab[i-1] && i<n)
{w++; 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 | #include <bits/stdc++.h> using namespace std; int tab[2005]; bool porownaj (int a, int b) {return a>b; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n,k,i,w=0; cin>>n>>k; for (i=0;i<n;i++) cin>>tab[i]; if (n<=k)cout<<n; else { sort(tab,tab+n,porownaj); i=k; w=k; while(tab[i]==tab[i-1] && i<n) {w++; i++; } cout<<w; } return 0; } |
English