Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <vector>
- int main() {
- auto cmp = [](int a, int b) {
- return a > b;
- };
- std::priority_queue<int, std::vector<int>, decltype(cmp)> Q(cmp);
- for(int a : {5, 3, 10, 2, 11}) {
- Q.push(a);
- std::cout << "TOP: " << Q.top() << std::endl;
- }
- while(!Q.empty()) {
- std::cout << Q.top() << std::endl;
- Q.pop();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment