123456xh @ 2022-05-26 18:34:08
#include<bits/stdc++.h>
using namespace std;
const int N=5000000;
int a[N];
void q_sort(int l,int m)
{
int mid = a[(l+m)/2];
int i=l,j=m;
do{
while(a[i]<mid)i++;
while(a[j]>mid)j--;
if(i<=j)
{
swap(a[i],a[j]);
i++;
j--;
}
}while(i<=j);
if (l<j) q_sort(l,j);
if (i<m) q_sort(i,m);
}
int main()
{
int k,n;
scanf("%d %d",&n,&k);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
q_sort(1,n);
for(int i=1;i<=n;i++)
{
if (i==k+1) printf("%d",a[i]);
}
}
by 123456xh @ 2022-05-29 10:49:33
没人???
by _cyle_King @ 2022-06-02 14:20:08
数组小了,再开大一点就行了,不过没有影响,这题会TLE。