#include <iostream> // std::cout
#include <algorithm> // std::sort
#include <vector> // std::vector
#define MAXN 2001
using namespace std;
int n,k;
vector<int> a;
int main() {
scanf("%d%d", &n, &k);
for (int i=0; i<n; ++i){
int x;
scanf("%d", &x);
a.push_back(x * (-1));
}
sort(a.begin(), a.end());
// for (auto x: a) cout << x << endl;
int dodatkowe_koszulki = 0;
for (int i=k; i<n && a[i] == a[k-1]; ++i, ++dodatkowe_koszulki);
printf("%d", k+dodatkowe_koszulki);
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 | #include <iostream> // std::cout #include <algorithm> // std::sort #include <vector> // std::vector #define MAXN 2001 using namespace std; int n,k; vector<int> a; int main() { scanf("%d%d", &n, &k); for (int i=0; i<n; ++i){ int x; scanf("%d", &x); a.push_back(x * (-1)); } sort(a.begin(), a.end()); // for (auto x: a) cout << x << endl; int dodatkowe_koszulki = 0; for (int i=k; i<n && a[i] == a[k-1]; ++i, ++dodatkowe_koszulki); printf("%d", k+dodatkowe_koszulki); return 0; } |
English