BBY123 @ 2023-03-03 18:47:22
#include<bits/stdc++.h>
using namespace std;
int n,k,a[5000001];
int ans=0;
void quicksort(int l,int r){
int i=l,j=r,flag=a[(l+r)/2];
while(i<=j){
while(a[i]<flag) i++;
while(a[j]>flag) j--;
if(i<=j){
swap(a[i],a[j]);
j--;
i++;
}
}
if(k<=j) quicksort(l,j);
else if(k>=i) quicksort(i,r);
else if(k>=j&&k<=i)return;
}
int main(){
cin>>n>>k;
for(int i = 0;i < n;i++){
cin>>a[i];
}
quicksort(0,n-1);
cout<<a[k];
return 0;
}
by KamisatO__Ayaka @ 2023-03-25 21:22:01
十年OI一场空,不用scanf见祖宗