#include <cstdio> #include <functional> #include <algorithm> using namespace std; #define MAXN 2100 int pts[MAXN]; int N, K; int main() { scanf("%d %d", &N, &K); for (int i = 0; i < N; ++i) scanf("%d", &pts[i]); sort(&pts[0], &pts[N], greater<int>()); for (int i = K; i < N; ++i) { if (pts[i] != pts[i-1]) { printf("%d\n", i); return 0; } } printf("%d\n", N); 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 26 27 28 29 30 | #include <cstdio> #include <functional> #include <algorithm> using namespace std; #define MAXN 2100 int pts[MAXN]; int N, K; int main() { scanf("%d %d", &N, &K); for (int i = 0; i < N; ++i) scanf("%d", &pts[i]); sort(&pts[0], &pts[N], greater<int>()); for (int i = K; i < N; ++i) { if (pts[i] != pts[i-1]) { printf("%d\n", i); return 0; } } printf("%d\n", N); return 0; } |