```cpp
#include <bits/stdc++.h>
using namespace std;
int n,r,q;
struct node{
int x,y,i;
} a[2000001];
node at[1000001]={},bt[1000001]={};
bool cmp (node x,node y) {return x.x>y.x||(x.x==y.x&&x.i<y.i);}
int main ()
{
cin>>n>>r>>q;
for (int i=1;i<=n*2;i++) cin>>a[i].x,a[i].i=i;
for (int i=1;i<=n*2;i++) cin>>a[i].y;
sort (a+1,a+n*2+1,cmp);
for (int i=1;i<=r;i++)
{
int as=0,bs=0;
for (int j=1;j<=n*2;j+=2)
if (a[j].y>a[j+1].y)
{
a[j].x++;
at[++as]=a[j];
bt[++bs]=a[j+1];
}else
{
a[j+1].x++;
at[++as]=a[j+1];
bt[++bs]=a[j];
}
int j=0, p1 = 1, p2 = 1;
while (p1 <= as && p2 <= bs)
if (cmp(at[p1], bt[p2]))
{
a[++j]=at[p1];
p1++;
}else
{
a[++j]=bt[p2];
p2++;
}
while (p1 <= as) a[++ j] = at[p1 ++];
while (p2 <= bs) a[++ j] = bt[p2 ++];
}
cout<<a[q].i<<endl;
return 0;
}
````````
AC亲测求关
by HEROBRINEH @ 2024-02-27 17:23:58
@[HEROBRINEH](/user/1113507) 谢谢佬的代码,已关,但可以帮我看看我的问题吗?
by Xiaoyang661 @ 2024-02-28 11:54:50
$sort$ 确实会卡20分
by ReturnXI @ 2024-04-23 21:47:55