排序-快排-第k小的数
//这里判断j >= (k - 1)
//最后返回q[l]即可
#include<iostream>
using namespace std;
const int N = 100010;
int n, k;
int q[N];
int quicksort(int* q, int l, int r) {
if (l >= r) return q[l];
int x = q[(l + r) / 2];
int 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 (j >= (k - 1)) quicksort(q, l, j);
else quicksort(q, j + 1, r);
}
int main(){
scanf("%d%d", &n, &k);
for (int i = 0; i < n; i ++ ) scanf("%d", &q[i]);
cout << quicksort(q, 0, n - 1) << endl;
return 0;
}