李敏镐的女人 @ 2022-03-20 20:34:44
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main{
static int a[];
static void quickSort(int left,int right){
int l=left;
int r=right;
int mid=a[(l+r)/2];
int temp=0;
while(l<r){
while(a[l]<mid)
l++;
while (a[r]>mid)
r--;
if(l>=r)
break;
temp=a[r];
a[r]=a[l];
a[l]=temp;
if(mid==a[r])
l++;
if(mid==a[l])
r--;
}
if(l==r){
l++;
r--;
}
if(l<right)
quickSort(l,right);
if(r>left)
quickSort(left,r);
}
public static void main(String[] args) throws Exception{
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
String[] one=reader.readLine().split(" ");
int n=Integer.parseInt(one[0]);
int ai=Integer.parseInt(one[1]);
String[] q=reader.readLine().split(" ");
reader.close();
a=new int[q.length];
for(int i=0;i<n;i++){
a[i]=Integer.parseInt(q[i]);
}
quickSort(0,n-1);
System.out.print(a[ai]);
}
}