#include <iostream> int main() { int k, n; std::cin >> k >> n; int score[121] = { 0 }; while (k--) { int a; std::cin >> a; ++score[a]; } int total = 0; for (int i = 120; i > 0; --i) { total += score[i]; if (total >= n) break; } std::cout << total << std::endl; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <iostream> int main() { int k, n; std::cin >> k >> n; int score[121] = { 0 }; while (k--) { int a; std::cin >> a; ++score[a]; } int total = 0; for (int i = 120; i > 0; --i) { total += score[i]; if (total >= n) break; } std::cout << total << std::endl; return 0; } |