Result: Accepted
Time: 12ms
Memory: 1092kB
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define size 200
struct student
{
char name[31];
int a;
int b;
int all;
};
int comp(const void *p,const void *q)
{
return ((struct student *)q)->all-((struct student *)p)->all;
}
int main()
{
int T,i,len,k,flag;
long int n,j;
struct student olw[size];
scanf("%d",&T);
for(i=0;i<T;i++)
{
scanf("%d",&n);
for(j=0;j<n;j++)
{
scanf("%s%d%d",olw[j].name,&olw[j].a,&olw[j].b);
olw[j].all=olw[j].a+olw[j].b;
}
qsort(olw,n,sizeof(struct student),comp);
for(j=0;j<n;j++)
{
printf("%s\n",olw[j].name);
}
}
return 0;
}