#include <iostream> #include <algorithm> using namespace std; int n,k; int pts[2000]; int main() { cin >> n >> k; for(int i=0; i<n; i++) { cin >> pts[i]; } sort(pts,pts+n,greater<>()); while(k < n && pts[k]==pts[k-1]) k++; cout << k << endl; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include <iostream> #include <algorithm> using namespace std; int n,k; int pts[2000]; int main() { cin >> n >> k; for(int i=0; i<n; i++) { cin >> pts[i]; } sort(pts,pts+n,greater<>()); while(k < n && pts[k]==pts[k-1]) k++; cout << k << endl; } |