题解 | #小白鼠排队#

小白鼠排队

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

全部评论

相关推荐

落花情:同学,瞅瞅我司,医疗独角兽,校招刚开,名额有限,先到先得,我的主页最新动态,绿灯直达,免笔试~
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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