1 条题解

  • 0
    @ 2026-5-22 8:51:02
    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(NULL);
    
        int q; cin >> q;
        queue<int> qu;
        priority_queue<int, vector<int>, greater<int>> pq;
    
        while(q--) {
            int t; cin >> t;
    
            if(t == 1) {
                int x; cin >> x;
                qu.push(x);
            }
            else if(t == 2) {
                if(!pq.empty()) {
                    cout << pq.top() << '\n';
                    pq.pop();
                } else {
                    cout << qu.front() << '\n';
                    qu.pop();
                }
            }
            else {
                while(!qu.empty()) {
                    pq.push(qu.front());
                    qu.pop();
                }
            }
        }
    }
    • 1

    信息

    ID
    12212
    时间
    2000ms
    内存
    1024MiB
    难度
    8
    标签
    递交数
    31
    已通过
    5
    上传者