Result: Accepted
Time: 22ms
Memory: 1092kB
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int comp(const void*p,const void*q)
{
return (*(int*)p-*(int*)q);
}
int main()
{
int t,i;
scanf("%d",&t);
for(i=1;i<=t;++i)
{
int n,m;
char a[100][31];
int x,y,zong[101];
scanf("%d",&n);
for(m=0;m<n;m++)
{
getchar();
scanf("%s",a[m]);
scanf("%d%d",&x,&y);
zong[m]=x+y;
}
int pass,j,temp;
for(pass=1;pass<n;++pass)
{
char b[31];
for(j=0;j<n-pass;++j)
{
if(zong[j]<zong[j+1])
{
temp=zong[j];
zong[j]=zong[j+1];
zong[j+1]=temp;
strcpy(b,a[j]);
strcpy(a[j],a[j+1]);
strcpy(a[j+1],b);
}
}
}
for(m=0;m<n;m++)
{
puts(a[m]);
}
}
return 0;
}