Maxzero @ 2019-05-03 15:10:27
using namespace std; int main() {
cin>>n;
while(i<=n)
{
cin>>a>>b>>c;
x[i]=a+b+c;
y[i]=a;
i++;
}
i=1;
while(i<=n)
{
if(x[i]>t1)t1=x[i],l1=i;
else if(x[i]==t1&&y[i]>y[l1])l1=i;
i++;
}
i=1;
while(i<=n)
{
if(x[i]>t2&&i!=l1)t2=x[i],l2=i;
else if(x[i]==t2&&y[i]>y[l2]&&i!=l1)l2=i;
i++;
}
i=1;
while(i<=n)
{
if(x[i]>t3&&i!=l1&&i!=l2)t3=x[i],l3=i;
else if(x[i]==t2&&y[i]>y[l2]&&i!=l1&&i!=l2)l3=i;
i++;
}
i=1;
while(i<=n)
{
if(x[i]>t4&&i!=l1&&i!=l2&&i!=l3)t4=x[i],l4=i;
else if(x[i]==t2&&y[i]>y[l2]&&i!=l1&&i!=l2&&i!=l3)l4=i;
i++;
}
i=1;
while(i<=n)
{
if(x[i]>t5&&i!=l1&&i!=l2&&i!=l3&&i!=l4)t5=x[i],l5=i;
else if(x[i]==t2&&y[i]>y[l2]&&i!=l1&&i!=l2&&i!=l3&&i!=l4)l5=i;
i++;
}
if(n>=1)cout<<l1<<" "<<t1<<endl; if(n>=2)cout<<l2<<" "<<t2<<endl; if(n>=3)cout<<l3<<" "<<t3<<endl; if(n>=4)cout<<l4<<" "<<t4<<endl; if(n>=5)cout<<l5<<" "<<t5<<endl; }