Result: Accepted
Time: 11ms
Memory: 1096kB
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
struct stu{
char name[35];
int a,b,c;
}s[100];
int comp(const void *p,const void *q)
{
struct stu *x = (struct stu *)p;
struct stu *y = (struct stu *)q;
return (*y).c - (*x).c;
}
int main() {
int t,n;
int pass,i,temp;
//stu s[100];
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(int g=0;g<n;g++){
scanf("%s %d %d",&s[g].name,&s[g].a,&s[g].b);
s[g].c = s[g].a + s[g].b;
}
/*for(pass=0;pass<n;++pass){
for(i=0;i<n-pass;++i){
if(s[i].c<s[i+1].c){
temp=s[i].c;
s[i].c=s[i+1].c;
s[i+1].c=temp;
char cc[35];
strcpy(cc,s[i].name);
strcpy(s[i].name,s[i + 1].name);
strcpy(s[i + 1].name,cc);
}
}
}*/
qsort(s,n,sizeof(struct stu),comp);
for(int p=0;p<n;p++){
printf("%s\n",s[p].name);
}
}
}