题目描述 https://www.luogu.org/problemnew/show/P1093
多个因素排序
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
int sc,ch,nm;
}a[305];
int n;
bool cmp(const node &a,const node &b)
{
if(a.sc!=b.sc) return a.sc>b.sc;
if(a.ch!=b.ch) return a.ch>b.ch;
return a.nm<b.nm;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
a[i].sc=x+y+z;
a[i].ch=x;
a[i].nm=i;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++)
printf("%d %d\n",a[i].nm,a[i].sc);
return 0;
}