wu
2023-09-13 20:09:15
发布于:广东
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+10;
struct node{
int id;
int s;
int w;
}a[MAXN];
bool cmp(node a,node b)
{
if(a.sb.s)
return a.id<b.id;
return a.s>b.s;
}
int main()
{
int n,r,q;
queue<node> win,lose;
cin>>n>>r>>q;
n*=2;
int cnt;
node win_0,lose_0;
for(int i=1;i<=n;++i)
{
cin>>a[i].s;
a[i].id=i;
}
for(int i=1;i<=n;i)
{
cin>>a[i].w;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=r;i)
{
for(int j=1;j<=n-1;j+=2)
{
if(a[j].w>a[j+1].w)
{
a[j].s;
win.push(a[j]);
lose.push(a[j+1]);
}
else
{
a[j+1].s;
win.push(a[j+1]);
lose.push(a[j]);
}
}
cnt=0;
while(!win.empty() && !lose.empty())
{
win_0=win.front();
lose_0=lose.front();
if(win_0.s>lose_0.s || (win_0.slose_0.s && win_0.id<lose_0.id))
{
cnt++;
a[cnt]=win.front();
win.pop();
}
else{
cnt++;
a[cnt]=lose.front();
lose.pop();
}
}
while(!win.empty())
{
cnt++;
a[cnt]=win.front();
win.pop();
}
while(!lose.empty())
{
cnt++;
a[cnt]=lose.front();
lose.pop();
}
}
cout<<a[q].id;
return 0;
}
这里空空如也
有帮助,赞一个