#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2000;
int t1[MAX_N];
int main() {
int n, k;
cin >> n >> k;
for (int i = 0; i < n; ++i) {
cin >> t1[i];
}
sort(t1, t1+n, greater<int>());
int i = k;
while (t1[i] == t1[i-1] && i < n) {
++i;
}
cout << i;
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; const int MAX_N = 2000; int t1[MAX_N]; int main() { int n, k; cin >> n >> k; for (int i = 0; i < n; ++i) { cin >> t1[i]; } sort(t1, t1+n, greater<int>()); int i = k; while (t1[i] == t1[i-1] && i < n) { ++i; } cout << i; return 0; } |
English