牛客网题目链接
简单的排序题
常用的方法是用结构体
但是这道题只有两个变量可以用pair
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cctype>
using namespace std;
const int N = 105;
typedef pair<int, string> PII;
vector<PII> vt;
int main(){
int n;
while(cin>>n){
vt.clear();
int w;
string c;
for(int i = 0; i < n; i++){
cin>>w>>c;
vt.push_back({w,c});
}
sort(vt.rbegin(), vt.rend());
for(auto x: vt){
cout<<x.second<<endl;
}
}
return 0;
}