#include <iostream>
#include <algorithm>
using namespace std;
int n,k,t[2008],x;
int main()
{
cin>>n>>k;
for(int i=0;i<n;i++)
{
cin>>x;
t[i] = -x;
}
sort(t,t+n);
while(t[k-1]==t[k])
{
k++;
}
cout<<k;
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <iostream> #include <algorithm> using namespace std; int n,k,t[2008],x; int main() { cin>>n>>k; for(int i=0;i<n;i++) { cin>>x; t[i] = -x; } sort(t,t+n); while(t[k-1]==t[k]) { k++; } cout<<k; return 0; } |
English