#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
vector<int> points;
int n,k;
cin>>n>>k;
while(n--){
int ai;
cin>>ai;
points.push_back(ai);
}
sort(points.begin(),points.end(),greater<int>());
int it = k-1;
while(it<points.size() && points[it+1]==points[it]) it++;
cout<<it+1<<endl;
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 | #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ vector<int> points; int n,k; cin>>n>>k; while(n--){ int ai; cin>>ai; points.push_back(ai); } sort(points.begin(),points.end(),greater<int>()); int it = k-1; while(it<points.size() && points[it+1]==points[it]) it++; cout<<it+1<<endl; return 0; } |
English