题解 | #小白鼠排队#

小白鼠排队

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

全部评论

相关推荐

05-30 12:03
山西大学 C++
offer来了我跪着接:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
白火同学:大二有这水平很牛了,可以适当对关键信息加粗一点,比如关键技术、性能指标之类的。
点赞 评论 收藏
分享
长鑫存储
投递长鑫存储等公司7个岗位 >
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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