题解 | #小白鼠排队#
小白鼠排队
https://www.nowcoder.com/practice/27fbaa6c7b2e419bbf4de8ba60cf372b
#include <bits/stdc++.h>
using namespace std;
class rat{
public:
string hat;
int weight;
};
bool cmp(rat r1, rat r2){
return r1.weight>r2.weight;
}
int main() {
int n;cin>>n;
vector<rat>v;
while(n--){
int temp;string s;
cin>>temp>>s;
rat r;
r.hat = s;
r.weight = temp;
v.push_back(r);
}
sort(v.begin(),v.end(),cmp);
for(auto r:v)
cout<<r.hat<<endl;
}
// 64 位输出请用 printf("%lld")

查看5道真题和解析