EndOfFuture @ 2023-02-09 19:30:52
rt,n长度 5e7
#include <bits/stdc++.h>
using namespace std;
int nl[50000000],c;
void SWAP(int i,int j){
int tmp=nl[j];
nl[j]=nl[i];
nl[i]=tmp;
}
void Fnd(int l,int r){
if(l==r){
printf("%d",nl[l]);
return;
}
int i=l,j=r,k=nl[(l+r)/2];
do{
while(nl[j]>k)--j;
while(nl[i]<k)++i;
if(i<=j){SWAP(i,j);++i;--j;}
}while(i<=j);
if(c<=j)Fnd(l,j);
else if(i<=c)Fnd(i,r);
else Fnd(i+1,j-1);
}
int main(){
int n;
scanf("%d %d",&n,&c);
for(int i=0;i<n;++i){
scanf("%d",&nl[i]);
}
Fnd(0,n-1);
return 0;
}