大佬们求助!!!!
查看原帖
大佬们求助!!!!
226367
glorious_dream楼主2021/9/8 21:27
#include<bits/stdc++.h>
using namespace std;
int n,r,q;
const int M = 500010;
struct student{
	int chu,shi;
	int id;
	int fen;
}a[M];
bool cmp(student a,student b){
	if(a.fen == b.fen){
		return a.id < b.id;
	}
	return a.fen > b.fen;
}
int main(){
	scanf("%d%d%d",&n,&r,&q);
	for(int i=1 ; i<=2*n ; i++){
		cin >> a[i].chu;
		a[i].id = i;
		a[i].fen = a[i].chu;
	}
	for(int i=1 ; i<=2*n ; i++){
		cin >> a[i].shi;
	}
	sort(a+1,a+2*n+1,cmp);
	for(int j=1 ; j<=r ; j++){
		for(int i=1 ; i<=r ; i+=2){
			if(a[i].shi < a[i+1].shi){
				a[i+1].fen+=1;
			}
			if(a[i].shi > a[i+1].shi){
				a[i].fen += 1;
			}
		}
		sort(a+1,a+2*n+1,cmp);
	}
	cout << a[q].id;
	return 0;
}
2021/9/8 21:27
加载中...