Harrison_001 @ 2023-06-18 10:51:10
#include <bits/stdc++.h>
using namespace std;
int n;
struct STU{
int yw;
int sx;
int yy;
int xh;
int zf;
} a[310];
bool cmp(STU x,STU y){
return x.zf>y.zf || x.zf==y.zf && x.yw>y.yw ||\
x.zf==y.zf && x.yw==y.yw && x.xh>y.xh;
}
int main()
{
cin >>n;
for(int i=1;i<=n;i++){
cin >>a[i].yw >>a[i].sx >>a[i].yy;
a[i].xh=i;
a[i].zf=a[i].yw+a[i].sx+a[i].yy;
}
sort(a+1,a+1+n,cmp);
for(int i=1;i<=5;i++){
cout <<a[i].xh <<" " <<a[i].zf <<endl;
}
return 0;
}
by Harrison_001 @ 2023-06-18 10:55:34
已A
by XSean @ 2023-06-18 11:03:43
@miniworldyyds 将
bool cmp(STU x,STU y){
return x.zf>y.zf || x.zf==y.zf && x.yw>y.yw ||\
x.zf==y.zf && x.yw==y.yw && x.xh>y.xh;
}
改为
bool cmp(STU x,STU y){
return x.zf>y.zf || x.zf==y.zf && x.yw>y.yw ||\
x.zf==y.zf && x.yw==y.yw && x.xh<y.xh;
}