Result: Accepted
Time: 18ms
Memory: 1092kB
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct stttd{
char name[31];
int l;
int s;
};
int main(){
int t,i,j,n;
scanf("%d",&t);
while(t--){
struct stttd student[100],temp;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %d%d",student[i].name,&student[i].l,&student[i].s);
}
for(i=0;i<n-1;i++){
for(j=0;j<n-1-i;j++){
if(student[j].l+student[j].s<student[j+1].l+student[j+1].s){
strcpy(temp.name,student[j].name);
strcpy(student[j].name,student[j+1].name);
strcpy(student[j+1].name,temp.name);
temp.l=student[j].l;
student[j].l=student[j+1].l;
student[j+1].l=temp.l;
temp.s=student[j].s;
student[j].s=student[j+1].s;
student[j+1].s=temp.s;
}
}
}
for(i=0;i<n;i++){
printf("%s\n",student[i].name);
}
}
}