Result: Accepted
Time: 28ms
Memory: 2080kB
#include <stdio.h>
#include <string.h>
#define ARRAY 1000
struct student{
char name[ARRAY];
int a, b;
int s;
}p[ARRAY], temp;
int main(void){
int i, T, n, pass, j;
//char ch[ARRAY];
scanf("%d", &T);
//getchar();
while(T--){
scanf("%d", &n);
//getchar();
for(i = 0; i < n; i++){
getchar();
scanf("%s %d %d", p[i].name, &p[i].a, &p[i].b);
p[i].s = p[i].a + p[i].b;
}
for(pass = 1; pass < n; pass++){
for(j = 0; j < n - pass; j++){
if(p[j].s < p[j + 1].s){
temp = p[j];
p[j] = p[j + 1];
p[j + 1] = temp;
}
}
}
for(i = 0; i < n; i++){
printf("%s\n", p[i].name);
}
}
return 0;
}