fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // priority_queue
  6. // push
  7. // size
  8. // top pop empty
  9. priority_queue<int> pq;
  10. pq.push(1);
  11. pq.push(5);
  12. pq.push(2);
  13. pq.push(6);
  14.  
  15. cout << pq.top(); // print 6
  16. cout << endl;
  17. pq.pop();
  18. cout << pq.top(); // print 5
  19. cout << endl;
  20.  
  21. priority_queue<pair<int,int>> pq2;
  22. pq2.push({1, 5});
  23. pq2.push({1, 6});
  24. pq2.push({1, 7});
  25. cout << pq2.top().first << " " << pq2.top().first << endl;
  26.  
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
6
5
1 1