//
// main.cpp
// 2021-1-kos-koszulki
//
// Created by Marek on 06/12/2021.
//
#include <iostream>
#include <algorithm>
constexpr int MAXN = 1e4;
int t[MAXN];
int main(int argc, const char * argv[]) {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
int n, k;
std::cin >> n >> k;
for (int i = 0; i < n; i++) {
std::cin >> t[i];
}
std::sort(t, t + n, std::greater<int>());
int l;
t[n] = -1;
for (l = k - 1; t[k - 1] == t[l]; l++);
std::cout << l << '\n';
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 24 25 26 27 28 29 30 | // // main.cpp // 2021-1-kos-koszulki // // Created by Marek on 06/12/2021. // #include <iostream> #include <algorithm> constexpr int MAXN = 1e4; int t[MAXN]; int main(int argc, const char * argv[]) { std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0); int n, k; std::cin >> n >> k; for (int i = 0; i < n; i++) { std::cin >> t[i]; } std::sort(t, t + n, std::greater<int>()); int l; t[n] = -1; for (l = k - 1; t[k - 1] == t[l]; l++); std::cout << l << '\n'; return 0; } |
English