//
// main.cpp
// Priority Queue
//
// Created by Himanshu on 19/09/21.
//
#include <iostream>
#include <queue>
using namespace std;
int main ( ) {
priority_queue< int > pq;
cout << "Insert Q(x) {30, 100, 25, 40}" << endl;
pq.push ( 30 ) ;
pq.push ( 100 ) ;
pq.push ( 25 ) ;
pq.push ( 40 ) ;
cout << "Maximum Element (Q)" << endl;
cout << pq.top ( ) << endl;
cout << "Maximum Element (Q) after Extract-Max (Q)" << endl;
pq.pop ( ) ;
cout << pq.top ( ) << endl;
cout << "Extracting out elements..." << endl;
while ( ! pq.empty ( ) ) {
cout << pq.top ( ) << " " ;
pq.pop ( ) ;
}
cout << endl;
if ( pq.empty ( ) ) {
cout << "Priority queue is empty" << endl;
} else {
cout << "Priority queue is not empty" << endl;
}
return 0 ;
}
Ly8KLy8gIG1haW4uY3BwCi8vICBQcmlvcml0eSBRdWV1ZQovLwovLyAgQ3JlYXRlZCBieSBIaW1hbnNodSBvbiAxOS8wOS8yMS4KLy8KCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHF1ZXVlPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4gKCkgewogICAgCiAgICBwcmlvcml0eV9xdWV1ZTxpbnQ+IHBxOwogICAgCiAgICBjb3V0PDwiSW5zZXJ0IFEoeCkgezMwLCAxMDAsIDI1LCA0MH0iPDxlbmRsOwogICAgcHEucHVzaCgzMCk7CiAgICBwcS5wdXNoKDEwMCk7CiAgICBwcS5wdXNoKDI1KTsKICAgIHBxLnB1c2goNDApOwogICAgCiAgICBjb3V0PDwiTWF4aW11bSBFbGVtZW50IChRKSI8PGVuZGw7CiAgICBjb3V0PDxwcS50b3AoKTw8ZW5kbDsKICAgIAogICAgY291dDw8Ik1heGltdW0gRWxlbWVudCAoUSkgYWZ0ZXIgRXh0cmFjdC1NYXggKFEpIjw8ZW5kbDsKICAgIHBxLnBvcCgpOwogICAgY291dDw8cHEudG9wKCk8PGVuZGw7CiAgICAKICAgIGN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