解法:
统计个数用数组做桶即可
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define endl '\n'
int main()
{
vector<int> tong(301, 0);
int n, m, a;
cin >> n >> m;
while (n--) {
cin >> a;
tong[a]++;
}
long long sum = 0;
for (int i = 300; ~i; i--) {
sum += tong[i];
if (sum >= m) {
cout << i << endl;
return 0;
}
}
return 0;
}