Result: Accepted
Time: 13ms
Memory: 1092kB
#include <stdio.h>
#include <stdlib.h>
struct student{
char name[21];
double lc;
double sc;
double total;
};
int comp(const void *p,const void *q){
return ((struct student *)q)->total-((struct student *)p)->total;
}
int main(void)
{
struct student a[101];
int N;
int T;
scanf("%d",&N);
while(N--)
{
scanf("%d",&T);
for(int i=0;i<T;++i)
{
scanf("%s %lf %lf",a[i].name,&a[i].lc,&a[i].sc);
a[i].total=a[i].lc+a[i].sc;
}
qsort(a,T,sizeof(struct student),comp);
for(int j=0;j<T;++j)
{
printf("%s\n",a[j].name);
}
}
return 0;
}