Result: Accepted
Time: 3ms
Memory: 1120kB
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
getchar();
int i=0;
int m;
m=n;
char a[105][40];
int b[105];
while(n--){
scanf("%s%d",a[i],&b[i]);
getchar();
i++;
}
int temp1=0;
char tem[200];
for(int o=0;o<m-1;o++){
for(int e=0;e<m-o-1;e++){
if(b[e]<b[e+1]){
temp1=b[e+1];
b[e+1]=b[e];
b[e]=temp1;
strcpy(tem,a[e+1]);
strcpy(a[e+1],a[e]);
strcpy(a[e],tem);
}}
}
for(int q=0;q<m;q++){
printf("%s\n",a[q]);
}
}
}