此题用sort()
和vector<>
做,时间复杂度为O(n log n),根本过不了。可为什么……
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int n, k;
vector <int> a;
int main(){
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> k;
for(int i = 0, tmp; i < n; i++){
cin >> tmp;
a.push_back(tmp);
}
sort(a.begin(), a.end());
cout << a[k];
return 0;
}
![记录详情]()
???