题解 | #小白鼠排队#

小白鼠排队

https://www.nowcoder.com/practice/27fbaa6c7b2e419bbf4de8ba60cf372b

#include<iostream>
#include<algorithm>
using namespace std;

const int N = 1e5 + 10;

struct Rat {
    int m;
    string color;
} rats[N];

bool cmp(Rat r1, Rat r2) {
    return r1.m > r2.m;
}

int main(void) {
    int n;
    while (cin >> n) {
        for (int i = 0; i < n; i++) {
            cin >> rats[i].m >> rats[i].color;
        }
        sort(rats, rats + n, cmp);
        for (int i = 0; i < n; i++) {
            cout << rats[i].color << endl;
        }
    }


    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 13:05
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-07 18:05
哈哈哈哈哈感觉朋友找工作的已经疯掉了,直接上图
码农索隆:真老板娘:“我嘞个去,这不我当年的套路吗
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
今天 12:20
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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