#include <vector>
#include <iostream>
#include <algorithm>
int main(int argc, char const *argv[])
{
int n, k, a;
std::vector<int> points;
std::cin >> n;
std::cin >> k;
for (int i = 0; i < n; i++)
{
std::cin >> a;
points.push_back(a);
}
std::sort(points.rbegin(), points.rend());
while (k < n && points[k - 1] == points[k])
{
k++;
}
std::cout << k;
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 | #include <vector> #include <iostream> #include <algorithm> int main(int argc, char const *argv[]) { int n, k, a; std::vector<int> points; std::cin >> n; std::cin >> k; for (int i = 0; i < n; i++) { std::cin >> a; points.push_back(a); } std::sort(points.rbegin(), points.rend()); while (k < n && points[k - 1] == points[k]) { k++; } std::cout << k; return 0; } |
English