qawsedo @ 2023-01-05 18:27:25
那里有错误啊
#include<iostream>
#include <algorithm>
using namespace std;
const int N = 1e8 + 10;
int q[N];
int qa(int q[], int r, int l,int s)
{
if (r == l)
return q[l];
int z = r - 1, x = l + 1, c = q[r + l >> 1];
while (z < x)
{
do z++; while (q[z] < c);
do x--; while (q[x] > c);
if (z < x) swap(q[z], q[x]);
}
int v=x-r+1;
if (v >= s)
return qa(q, r, x, s);
return qa(q, x + 1, l, s - v);
}
int main()
{
int a,s;
cin >> a >> s;
for (int i = 0; i < a; i++)
scanf("%d",&q[i]);
cout<<qa(q, 0, a - 1,s);
return 0;
}