#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false); cin.tie(nullptr);
size_t n, k;
cin >> n >> k;
vector<int> A(n);
for(auto& a : A)
cin >> a, a = -a;
sort(A.begin(), A.end());
cout << (upper_bound(A.begin(), A.end(), A[k-1]) - A.begin()) << endl;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); size_t n, k; cin >> n >> k; vector<int> A(n); for(auto& a : A) cin >> a, a = -a; sort(A.begin(), A.end()); cout << (upper_bound(A.begin(), A.end(), A[k-1]) - A.begin()) << endl; } |
English