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

【模板】整数优先队列

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

#include <bits/stdc++.h>
#include <queue>
using namespace std;

int main() {
    priority_queue<int> pq;
    int q,op,x;
    cin >> q;
    while (q--) {
        cin >> op;
        if(op == 1)
        {
            cin >> x;
            pq.push(-x);
        }
        if(op == 2)
        {
            cout << -pq.top() << endl;
        }
         if(op == 3)
        {
            pq.pop();
        }
    
    }

}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

02-15 14:18
已编辑
江西工程学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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