sccccc @ 2023-09-26 18:18:09
#include <bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
const int N=5e6+10;
int q[N];
int n,k;
void quick_sort(int q[],int l,int r)
{
int x=q[l+r>>1],i=l-1,j=r+1;
while(i<j)
{
do i++; while(q[i]<x);
do j--; while(q[j]>x);
if(i<j) swap(q[i],q[j]);
}
if(k<j)quick_sort(q,l,j);
else if(j<k)quick_sort(q,j+1,r);
else if(j==k) pr("%d",q[j]),system("pause"),exit(0);
}
int main()
{
sc("%d %d",&n,&k);
for(int i=0;i<n;i++) sc("%d",&q[i]);
quick_sort(q,0,n-1);
system("pause");
return 0;
}