#include<bits/stdc++.h>//./
using namespace std;
struct student
{
int ch,ma,en,tot;
int num;
}stu[100];
bool cmp(student a,student b)
{
if(a.tot!=b.tot)return a.tot>b.tot;
else if(a.ch!=b.ch)return a.ch>b.ch;
else return a.num<b.num;
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>stu[i].ch>>stu[i].ma>>stu[i].en;stu[i].num=i;
stu[i].tot=stu[i].ch+stu[i].ma+stu[i].en;
}
sort(stu+1,stu+n+1,cmp);
for(int i=1;i<=5;i++)
cout<<stu[i].num<<' '<<stu[i].tot<<'\n';
}
自认为还有救,但不知道错在了哪儿。