#include <bits/stdc++.h>
using namespace std;
int n,k;
int t[2001];
int main()
{
scanf("%d%d",&n,&k);
for (int i=1; i<=n; i++)
{
scanf("%d",&t[i]);
}
sort(t+1,t+1+n);
reverse(t+1,t+1+n);
while (k+1<=n && t[k+1]==t[k]) k++;
printf("%d\n",k);
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <bits/stdc++.h> using namespace std; int n,k; int t[2001]; int main() { scanf("%d%d",&n,&k); for (int i=1; i<=n; i++) { scanf("%d",&t[i]); } sort(t+1,t+1+n); reverse(t+1,t+1+n); while (k+1<=n && t[k+1]==t[k]) k++; printf("%d\n",k); } |
English