O_00_00 @ 2021-11-14 10:08:33
#include<iostream>
using namespace std;
struct Student{
int ID,C,M,E,A;
};
void quicksort(Student a[],int l,int r){
if(l >= r) return;
int x = a[(l + r)/2].A;
int i = l - 1,j = r + 1;
while(i < j){
do i++;while(a[i].A > x);
do j--;while(a[j].A < x);
if(i < j) swap(a[i],a[j]);
}
quicksort(a,l,j);
quicksort(a,j+1,r);
}
int main(){
int n;
cin >> n;
Student a[n + 1];
for(int i = 1;i <= n;i++){
cin >> a[i].C >> a[i].M >> a[i].E;
a[i].A = a[i].C + a[i].M + a[i].E;
a[i].ID = i;
}
quicksort(a,1,n);
for(int i = 1;i <= 5;i++){
cout << a[i].ID << " " << a[i].A << endl;
}
return 0;
}