题解 | #小白鼠排队#

小白鼠排队

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")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务