题解 | 【模板】整数优先队列

【模板】整数优先队列

https://www.nowcoder.com/practice/a88e9711f7b04369982bbe8902278ae4

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

int main() {
    int n;
    cin>>n;
	// 使用multiset也可以
    multiset<int> ms;
    for(int i=0;i<n;i++){
        int op;
        cin>>op;
        if(op==1){
            int x;
            cin>>x;
            ms.insert(x);
        }else if(op==2){
            cout<<*ms.begin()<<endl;
        }else if(op==3){
            if(!ms.empty())
            ms.erase(ms.begin());
        }
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

点赞 评论 收藏
分享
哈哈哈,你是老六:百度去年裁员分评不好,赶紧弄点红包
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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