#include <iostream> #include <algorithm> int n, k; int scores[2000]; int main() { std::ios_base::sync_with_stdio(false); std::cin >> n >> k; for( int i = 0; i < n; i++ ) std::cin >> scores[i]; std::sort(scores, scores + n); std::cout << n - (std::lower_bound(scores, scores+n, scores[n-k]) - scores) << '\n'; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include <iostream> #include <algorithm> int n, k; int scores[2000]; int main() { std::ios_base::sync_with_stdio(false); std::cin >> n >> k; for( int i = 0; i < n; i++ ) std::cin >> scores[i]; std::sort(scores, scores + n); std::cout << n - (std::lower_bound(scores, scores+n, scores[n-k]) - scores) << '\n'; } |