P3378 【模板】堆

#include 
using namespace std;
priority_queue,greater > pq;
int main()
{
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        int op;
        cin >> op;
        switch(op)
        {
            case 1:
                int x;
                cin >> x;
                pq.push(x);
                break;
            case 2:
                cout << pq.top() << endl;
                break;
            case 3:
                pq.pop();
                break;
        }
    }
    return 0;
}

你可能感兴趣的:(洛谷题解,c++,洛谷)