Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- using namespace std;
- priority_queue<int> q;
- int ql, x;
- char cmd;
- int main(){
- scanf("%d", &ql);
- for(int i = 0; i < ql; ++i){
- scanf(" %c", &cmd);
- switch(cmd){
- case 'P':
- scanf("%d", &x);
- q.push(x);
- break;
- case 'Q':
- if(q.empty()){
- cout << "-1\n";
- } else {
- cout << q.top() << "\n";
- q.pop();
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement