提交时间:2024-12-12 16:32:23

运行 ID: 314054

#include <bits/stdc++.h> using namespace std; struct node { int xh; int y; int s; int ying; int fs; }; node a[102]; bool cmp(node x,node y) { if(x.fs==y.fs) { if(x.y>y.y) { return x.xh<y.xh; } else if(x.y<y.y) { return x.xh>y.xh; } else { if(x.xh>y.xh) { return x.xh<y.xh; } else { return x.xh>y.xh; } } } return x.fs>y.fs; } int main() { int b; cin>>b; for(int i=1;i<=b;i++) { cin>>a[i].y>>a[i].s>>a[i].ying; a[i].fs=a[i].y+a[i].s+a[i].ying; a[i].xh=i; } sort(a+1,a+b+1,cmp); for(int i=1;i<=5;i++) { cout<<a[i].xh<<" "<<a[i].fs<<endl; } return 0; }