Result: Accepted
Time: 3ms
Memory: 1764kB
#include<cstdio>
#include <algorithm>
#include <iostream>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=100005;
struct node
{
char a[21];
int b;
}arr[100];
bool cmp(const node &x,const node &y){
if(x.b!=y.b)return x.b>y.b;
return 0;
}
int main()
{
int t,n;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%s %d",arr[i].a,&arr[i].b);
}
sort(arr+1,arr+1+n,cmp);
for(int i=1;i<=n;i++)
{
printf("%s\n",arr[i].a);
}
}
// system("pause");
}