题解 | #小白鼠排队#

小白鼠排队

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

#include <bits/stdc++.h>
using namespace std;
struct node{
    int weight;
    string color;
   friend bool operator<(node  n1,node  n2)
	{
	     return n1.weight < n2.weight;
	}
};

int main(){
    int n;
    while(cin>>n){
        priority_queue<node> q;
        while(n--){
            node tmp;
            cin>>tmp.weight>>tmp.color;
            q.push(tmp);
        }
        while (q.size()>0) {
            cout<<q.top().color<<endl;
            q.pop();
        }
    }
    return 0;
}

全部评论

相关推荐

点赞 评论 收藏
分享
07-09 18:28
门头沟学院 Java
写着提前批,结果还要实习4个月以上???
程序员牛肉:这种不用看,直接投了,面试的时候问对应的HR就行。有可能他们是直接复制的暑期实习的模板。
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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