Result: Accepted
Time: 5ms
Memory: 1120kB
#include <stdio.h>
#define ARRAY 1000
#include <stdlib.h>
struct student{
char name[25];
int n;
};
int comp(const void *p,const void *q){
return ((struct student *)q)->n-((struct student *)p) ->n;
}
int main()
{
int t;
scanf("%d", &t);
while(t--){
struct student student11[ARRAY];
int n;
scanf("%d", &n);
int i, j;
for(i=0; i<n; i++){
scanf("%s %d", student11[i].name, &student11[i].n);
}
qsort(student11,n,sizeof(struct student),comp);
for(i=0; i<n; i++){
printf("%s\n", student11[i].name);
}
}
return 0;
}