Result: Accepted
Time: 12ms
Memory: 1092kB
#include <stdio.h>
#include<stdlib.h>
struct cyh{
char c[20];
int a,b;
int total;
};
int comp (const void *p,const void *q){
return ((struct cyh*)q)->total-((struct cyh*)p)->total;}
int main()
{ struct cyh cyh1[100];
int d,e,f;
scanf("%d",&d);
while(d--){
scanf("%d",&e);
for(f=0;f<e;f++)
{scanf("%s%d%d",cyh1[f].c,&cyh1[f].a,&cyh1[f].b);
cyh1[f].total =cyh1[f].a+cyh1[f].b;
}
qsort(cyh1,e,sizeof(struct cyh),comp);
for(f=0;f<e;f++)
{
printf("%s\n",cyh1[f].c);}
}}