#include <iostream> using namespace std; int main() { const int maxscore = 120; int n = 0, k = 0, sc[maxscore], j; for (int i = 0; i < maxscore; i++)sc[i] = 0; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> j; sc[j-1]++; } j = 0; for (int i = 119; 0 <= i; i--) { j += sc[i]; if (j >= k)break; } cout << j; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <iostream> using namespace std; int main() { const int maxscore = 120; int n = 0, k = 0, sc[maxscore], j; for (int i = 0; i < maxscore; i++)sc[i] = 0; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> j; sc[j-1]++; } j = 0; for (int i = 119; 0 <= i; i--) { j += sc[i]; if (j >= k)break; } cout << j; } |