#include <iostream>
#include <queue>
#include <vector>
int main() {
// Step 1: Include necessary headers
// Step 2: Define a custom comparison function for the min heap
auto cmp = [](const std::pair<int, int>& a, const std::pair<int, int>& b) {
return a.first > b.first;
};
// Step 3: Declare a min heap using a priority_queue and provide the comparison function
std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, decltype(cmp)> minHeap(cmp);
// Step 4: Add elements to the min heap
minHeap.push({5, 10});
minHeap.push({2, 20});
minHeap.push({8, 5});
minHeap.push({1, 15});
// Step 5: Pop and print elements from the min heap
while (!minHeap.empty()) {
std::pair<int, int> topElement = minHeap.top();
minHeap.pop();
std::cout << "First: " << topElement.first << ", Second: " << topElement.second << std::endl;
}
return 0;
}