Result: Accepted
Time: 13ms
Memory: 1092kB
#include<stdio.h>
#include<stdlib.h>
#define ARRAY_SIZE 150
struct s
{
char name[30];
int a,b,total;
};
int comp (const void*p,const void *q)
{
return ((struct s *)q)->total-((struct s *)p)->total;
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
struct s sArray[ARRAY_SIZE];
int i,n;
scanf("%d",&n);
for(i=0;i<n;++i)
{
scanf("%s %d %d",sArray[i].name ,&sArray[i].a,&sArray[i].b);
sArray[i].total =sArray[i].a+sArray[i].b;
}
qsort (sArray,n,sizeof(struct s),comp);
for(i=0;i<n;++i)
{
printf("%s\n",sArray[i].name );
}
}
}