30分求调,玄关*1
查看原帖
30分求调,玄关*1
1021365
Crab_Tang楼主2023/12/18 17:16
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=1e5+10;
int n,r,q;
struct peo{
	int s,w,id;
}a[2*N],b1[N],b2[N];
bool cmp(peo a,peo b){
	if(a.s==b.s)return a.id<b.id;
	return a.s>b.s;
}
int main(){
	scanf("%d %d %d",&n,&r,&q);
	for(int i=1;i<=2*n;++i){
		scanf("%d",&a[i].s);
		a[i].id=i;
	}
	for(int i=1;i<=2*n;++i)
		scanf("%d",&a[i].w);
	sort(a+1,a+2*n+1,cmp);
	for(int i=1;i<=r;++i){
		for(int j=2;j<=2*n;j+=2){
			if(a[j-1].w>a[j].w){
				++a[j-1].s;
				b1[j/2]=a[j-1];
				b2[j/2]=a[j];
			}
			else{
				++a[j].s;
				b1[j/2]=a[j];
				b2[j/2]=a[j-1];
			}
		}
		merge(b1+1,b1+1+n/2,b2+1,b2+1+n/2,a+1,cmp);
	}
	printf("%d",a[q].id);
	return 0;
}

STL的归并。s,w如题,id则为选手编号。

2023/12/18 17:16
加载中...