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