LJquq @ 2021-12-04 17:03:55
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
long long int n,k,a[1000000];
int main()
{
cin>>n>>k;
for(int i=0;i<=n;++i)
{
cin>>a[i];
}
nth_element(a,a+k,a+n);
cout<<a[k]<<endl;
return 0;
}
by 雨伞CKY @ 2021-12-04 17:23:25
@lijiaqi0608 数组开太小了
by Mkigita @ 2021-12-04 17:25:17
请尽量不要使用 nth_element 来写本题,因为本题的重点在于练习分治算法。
by LJquq @ 2021-12-05 09:46:13
@雨伞CKY 感谢