#include <iostream> #include <algorithm> using namespace std; #define MAX 100 struct rat{//常规方法,足够了 int weight; string hat; }; bool cmp(rat a,rat b){ return a.weight>b.weight; } int main() { int n; rat rats[MAX]; while(cin>>n){ for(int i=0;i<n;i++){ cin>>rats[i].weight>>rats[i].hat; } sort(rats,rats+n,cmp); for(int i=0;i<n;i++){ cout<<rats[i].hat<<endl; } } return 0; }