Result: Accepted
Time: 14ms
Memory: 1092kB
#include<stdio.h>
struct student{
char name[30];
int practice;
int theory;
int x;
};
int main(){
struct student a[200];
int b[200];
int T,i=0,N,s,j,temp1,c,temp2;
scanf("%d",&T);
while(i<T)
{scanf("%d",&N);
s=0;
while(s<N)
{scanf("%s%d%d",a[s].name,&a[s].theory,&a[s].practice);
b[s]=a[s].theory+a[s].practice;
a[s].x=s;
s++;}
s=0;
while(s<N){
j=0;
while(j<N-s-1){
if(b[j]>b[j+1])
{temp1=b[j];
temp2=a[j].x;
b[j]=b[j+1];
a[j].x=a[j+1].x;
b[j+1]=temp1;
a[j+1].x=temp2; }
j++;}
s++;}
s=N-1;
while(s!=-1)
{printf("%s\n",a[a[s].x].name);
s--;}
i++;}
}