4 solutions

  • 1
    @ 2026-8-24 16:05:21

    100分写法:

    #include<bits/stdc++.h>
    using namespace std;
    const int N=2e5+10;
    struct Node{
    	int sc;
    	int w;
    	int id;
    }s[N],q1[N],q2[N];
    bool cmp(Node a,Node b){
    	if(a.sc>b.sc) return 1;
    	if(a.sc==b.sc&&a.id<b.id) return 1;
    	return 0;
    }
    int main(){
    	int n,r,q;
    	cin>>n>>r>>q;
    	for(int i=1;i<=2*n;i++) cin>>s[i].sc;
    	for(int i=1;i<=2*n;i++){
    		cin>>s[i].w;
    		s[i].id=i;
    	}
    	sort(s+1,s+2*n+1,cmp);
    	while(r--){
    		for(int i=1;i<=2*n;i+=2){
    			if(s[i].w>s[i+1].w){
    				s[i].sc++;
    			}else{
    				s[i+1].sc++;
    			}
    		}
    		sort(s+1,s+2*n+1,cmp);
    	}
    	cout<<s[q].id;
    	return 0;
    }
    
    

    Information

    ID
    435
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    8
    Tags
    # Submissions
    72
    Accepted
    13
    Uploaded By