#include<cstdio>
#include<vector>
using namespace std;
const int MAX_POINTS = 120;
int main() {
int n;
int k;
vector<int> pointBuckets(MAX_POINTS, 0);
scanf("%d %d\n", &n, &k);
for (int i = 0; i < n; i++) {
int points;
scanf("%d", &points);
pointBuckets[points - 1]++;
}
int shirtsWon = 0;
for (int i = MAX_POINTS - 1; shirtsWon < k && i >= 0; i--) {
shirtsWon += pointBuckets[i];
}
printf("%d\n", shirtsWon);
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 31 | #include<cstdio> #include<vector> using namespace std; const int MAX_POINTS = 120; int main() { int n; int k; vector<int> pointBuckets(MAX_POINTS, 0); scanf("%d %d\n", &n, &k); for (int i = 0; i < n; i++) { int points; scanf("%d", &points); pointBuckets[points - 1]++; } int shirtsWon = 0; for (int i = MAX_POINTS - 1; shirtsWon < k && i >= 0; i--) { shirtsWon += pointBuckets[i]; } printf("%d\n", shirtsWon); return 0; } |
English