任艺宸 • 1个月前
#include<iostream> // cin\cout\endl
#include<cstdio> //scanf()\printf()
#include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset()
#include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min()
using namespace std;
struct yuan{
int x;
int w;
int m;
int e;
int z;
}a[301];
bool cmp(yuan x,yuan y){
if(x.z<y.z)return true;
else if(x.z==y.z){
if(x.w<y.w)return true;
else if(x.w==y.w)return x.x>y.x;
}
return false;
}
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
a[i].x=i+1;
cin>>a[i].w>>a[i].m>>a[i].e;
a[i].z=a[i].w+a[i].m+a[i].e;
}
for(int i=0;i<n-1;i++){
for(int j=0;j<n-i-1;j++){
if(cmp(a[j],a[j+1]))swap(a[j],a[j+1]);
}
}
for(int i=0;i<5;i++){
cout<<a[i].x<<" "<<a[i].z<<endl;
}
return 0;
}
评论: