#include <iostream>
#include <queue>
int main() {
// Step 1: Define a custom comparator for the inverse priority queue
struct InverseComparator {
bool operator()(const int& a, const int& b) const {
return a > b; // '>' results in an inverse priority queue
}
};
// Step 2: Declare an inverse priority queue using the custom comparator
std::priority_queue<int, std::vector<int>, InverseComparator> inversePriorityQueue;
// Step 3: Insert elements into the inverse priority queue
inversePriorityQueue.push(5);
inversePriorityQueue.push(2);
inversePriorityQueue.push(8);
// Step 4: Access the top element of the inverse priority queue
int topElement = inversePriorityQueue.top();
// Step 5: Print the top element
std::cout << "Top element of the inverse priority queue: " << topElement << std::endl;
// Step 6: Pop the top element from the inverse priority queue
inversePriorityQueue.pop();
// Step 7: Check if the inverse priority queue is empty
bool isEmpty = inversePriorityQueue.empty();
// Step 8: Print whether the inverse priority queue is empty or not
std::cout << "Is the inverse priority queue empty? " << (isEmpty ? "Yes" : "No") << std::endl;
return 0;
}