#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int k, n;
cin >> n >> k;
vector<int> v(n);
for(int i = 0; i < n; i++)
cin >> v[i];
sort(v.begin(), v.end(), greater<>());
while (k < n && v[k - 1] == v[k]) ++k;
cout << k << endl;
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include <bits/stdc++.h> using namespace std; int main(int argc, char* argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int k, n; cin >> n >> k; vector<int> v(n); for(int i = 0; i < n; i++) cin >> v[i]; sort(v.begin(), v.end(), greater<>()); while (k < n && v[k - 1] == v[k]) ++k; cout << k << endl; return 0; } |
English