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

int main()
{
    priority_queue <int> q;
    q.push(3);
    q.push(5);
    q.push(7);
    q.push(9);
    q.push(2);

    cout << q.top() << endl;
    q.pop();
    cout << q.top() << endl;
    return 0;
}

 

 

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

int main()
{
    priority_queue <int> q;
    q.push(-3);
    q.push(-5);
    q.push(-7);
    q.push(-9);
    q.push(-2);

    cout << -q.top() << endl;
    q.pop();
    cout << -q.top() << endl;
    return 0;


}

 

 

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

int main()
{
    priority_queue <int, vector<int>, greater<int>> q;
    q.push(3);
    q.push(5);
    q.push(7);
    q.push(9);
    q.push(2);

    cout << q.top() << endl;
    q.pop();
    cout << q.top() << endl;
    return 0;


}

+ Recent posts