听灌多求调
  • 板块灌水区
  • 楼主paulpao
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/10/3 10:16
  • 上次更新2024/10/3 12:20:20
查看原帖
听灌多求调
717437
paulpao楼主2024/10/3 10:16

P1309,60pts

#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int n,q,r;
struct py{
	int w,id,s;
}pl[2000001],x[2000001],y[2000001];
bool cmp(py a,py b){
	if(a.s!=b.s) return a.s>b.s;
	else return a.id<b.id;
}
int main(){
	cin>>n>>r>>q;	
	n*=2;
	for(int i=1;i<=n;i++){
		cin>>pl[i].s;
		pl[i].id=i;
	}
	for(int i=1;i<=n;i++){
		cin>>pl[i].w;
	}

	sort(pl+1,pl+n+1,cmp);
	for(int i=1;i<=r;i++){
		int cnt1=0,cnt2=0;
		for(int j=1;j<=n-1;j+=2){
			if(pl[j].w>pl[j+1].w){
				pl[j].s++;
				x[++cnt1]=pl[j];
				y[++cnt2]=pl[j+1];
			}
			else{
				pl[j+1].s++;
				x[++cnt1]=pl[j+1];
				y[++cnt2]=pl[j];
			}
			
		}
		merge(x+1,x+n+1,y+1,y+n+1,pl+1,cmp);
	}
	cout<<pl[q].id;
	return 0;
} 
2024/10/3 10:16
加载中...