2 solutions

  • 1
    @ 2026-1-2 16:18:17
    #include<bits/stdc++.h>
    using namespace std;
    struct Node{
    	int yu;
    	int shu;
    	int en;
    	int idx;
    	int zo;
    }arr[333];
    bool cmp(Node a,Node b){
    	if(a.zo>b.zo) return 1;
    	if(a.zo==b.zo&&a.yu>b.yu) return 1;
    	if(a.zo==b.zo&&a.yu==b.yu&&a.idx<b.idx) return 1;
    	return 0;
    }
    int main(){
    	int n;
    	cin>>n;
    	for(int i=1;i<=n;i++){
    		cin>>arr[i].yu>>arr[i].shu>>arr[i].en;
    		arr[i].zo=arr[i].yu+arr[i].shu+arr[i].en;
    		arr[i].idx=i;
    	}
    	sort(arr+1,arr+n+1,cmp);
    	for(int i=1;i<=5;i++){
    		cout<<arr[i].idx<<' '<<arr[i].zo<<endl;
    	}
    	return 0;
    }
    
    

    Information

    ID
    417
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    6
    Tags
    # Submissions
    15
    Accepted
    11
    Uploaded By