#include <bits/stdc++.h> using namespace std; int n, k, t[2002], r; int main() { scanf("%d%d", &n, &k); r = k; for (int i=0; i^n; ++i) { scanf("%d", &t[i]); } sort(t, t+n, greater<int>()); for (int i=k-1; i^2002; ++i) { //cout << t[i] << " " << t[i+1] << endl; if (t[i]^t[i+1]) { break; } ++r; } printf("%d", r); 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 <bits/stdc++.h> using namespace std; int n, k, t[2002], r; int main() { scanf("%d%d", &n, &k); r = k; for (int i=0; i^n; ++i) { scanf("%d", &t[i]); } sort(t, t+n, greater<int>()); for (int i=k-1; i^2002; ++i) { //cout << t[i] << " " << t[i+1] << endl; if (t[i]^t[i+1]) { break; } ++r; } printf("%d", r); return 0; } |