搞不懂明明有现成的 sort 函数,为什么还要写快排
题目描述
blablabla
样例
blablabla
include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
const int N = 100010;
int n, k;
int a[N];
/*
void quick_sort(int a[], int l, int r) {
if(l >= r) return;
int i = l - 1, j = r + 1, x = a[l + r >> 1];
while(i < j) {
do i++; while(a[i] < x);
do j–; while(a[j] > x);
if(i < j) swap(a[i],a[j]);
}
quick_sort(a, l, j);
quick_sort(a, j + 1, r);
}
*/
int main() {
scanf("%d %d",&n, &k);
for(int i = 0; i < n; i++){
scanf("%d",&a[i]);
}
sort(a, a + n);
printf("%d ",a[k - 1]);
return 0;
}