题解1
2023-11-19 15:43:40
发布于:广东
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,r,q;
struct player{
int idx,score,iq;
}a[2N],winner[N],loser[N];
bool cmp(player x,player y){
if(x.score!=y.score) return x.score>y.score;
return x.idx<y.idx;
}
int main(){
cin>>n>>r>>q;
for(int i=1;i<=2n;i++){
cin>>a[i].score;
a[i].idx=i;
}
for(int i=1;i<=2n;i++){
cin>>a[i].iq;
}
sort(a+1,a+n2+1,cmp);
while(r--){
int i1=1,i2=1;
for(int i=1;i<=2*n;i+=2){
if(a[i].iq>a[i+1].iq){
a[i].score++;
winner[i1++]=a[i];
loser[i2++]=a[i+1];
}else{
a[i+1].score++;
winner[i1++]=a[i+1];
loser[i2++]=a[i];
}
}
int i=1,j=1;
int idx=1;
while(i<=n&&j<=n){
if(cmp(winner[i],loser[j])){
a[idx++]=winner[i++];
}else{
a[idx++]=loser[j++];
}
}
while(i<=n){
a[idx++]=winner[i++];
}
while(j<=n){
a[idx++]=loser[j++];
}
}
cout<<a[q].idx;
return 0;
}
这里空空如也
有帮助,赞一个