#include <iostream>
#include <algorithm>
bool portownaj(short a, short b)
{
return a>b;
}
int main()
{
short n, k, x;
short punkty[2000]{};
std::cin >> n >> k;
x = k % (n+1);
for (int i = 0; i < n; ++i) std::cin >> punkty[i];
std::sort(punkty, punkty+(n), portownaj);
while(punkty[k-1]==punkty[x]) ++x;
std::cout << x;
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <iostream> #include <algorithm> bool portownaj(short a, short b) { return a>b; } int main() { short n, k, x; short punkty[2000]{}; std::cin >> n >> k; x = k % (n+1); for (int i = 0; i < n; ++i) std::cin >> punkty[i]; std::sort(punkty, punkty+(n), portownaj); while(punkty[k-1]==punkty[x]) ++x; std::cout << x; return 0; } |
English