求助,时间都去哪了
查看原帖
求助,时间都去哪了
214853
Mecci_miaowu楼主2020/12/8 22:14
#include<bits/stdc++.h>
using namespace std;
int n,q,r;
struct per{
	int id;
	int power;
	int score;
}p[200005];
queue<per>win;
queue<per>lose;
bool gz(per a,per b){
	if(a.score!=b.score)
		return a.score>b.score;
	return a.id<b.id;
}
int main(){
	scanf("%d %d %d",&n ,&r ,&q );
	for(int i=1;i<=2*n;++i)
		scanf("%d",&p[i].score);
	for(int i=1;i<=2*n;++i){
		scanf("%d",&p[i].power);
		p[i].id=i;
	}
	sort(p+1,p+2*n+1,gz);
	for(int i=1;i<=r;++i){
		for(int j=1,w,l;j<2*n;j+=2){
			if(p[j].power>p[j+1].power){
				w=j;
				l=j+1;
			}
			else{
				w=j+1;
				l=j;
			}
			++p[w].score;
			win.push(p[w]);
			lose.push(p[l]);
		}
		int cnt=1;
		while(!win.empty()&&!lose.empty()){
			if(gz(win.front(),lose.front())){
				p[cnt++]=win.front();
				win.pop();
			}
			else{
				p[cnt++]=lose.front();
				lose.pop();
			}
		}
		while(!lose.empty()){
			p[cnt++]=lose.front();
			lose.pop();
		}
		while(!win.empty()){
			p[cnt++]=win.front();
			win.pop();
		}
	}
	printf("%d",p[q].id);
	return 0;
}
2020/12/8 22:14
加载中...