#include <iostream> #include <algorithm> #include <functional> int main() { int contestants, minShirts; std::cin >> contestants >> minShirts; int* points = new int[contestants]; for (int i = 0; i < contestants; i++) { std::cin >> points[i]; } std::sort(points, points + contestants, std::greater<int>()); int counter = minShirts; while (points[counter] == points[counter - 1]) { counter++; } std::cout << counter; delete[] points; }
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 | #include <iostream> #include <algorithm> #include <functional> int main() { int contestants, minShirts; std::cin >> contestants >> minShirts; int* points = new int[contestants]; for (int i = 0; i < contestants; i++) { std::cin >> points[i]; } std::sort(points, points + contestants, std::greater<int>()); int counter = minShirts; while (points[counter] == points[counter - 1]) { counter++; } std::cout << counter; delete[] points; } |