提交时间:2024-08-19 20:40:14
运行 ID: 50334
#include<bits/stdc++.h> using namespace std; struct node{ int chn,mah,eng,sum,id; }; bool cmp(node a,node b){ if(a.sum==b.sum){ return a.id>b.id; }else return a.sum>b.sum; } int main(){ int n; cin>>n; node a[10000]; for(int i=0;i<n;i++){ cin>>a[i].chn>>a[i].mah>>a[i].eng; a[i].sum=a[i].chn+a[i].mah+a[i].eng; a[i].id=i+1; } sort(a,a+n,cmp); for(int i=0;i<5;i++){ cout<<a[i].id<<" "<<a[i].sum<<endl; } }