Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<queue>
- using namespace std;
- int main()
- {
- int k,i,x,ai;
- ai = 0;
- priority_queue<int> pq;
- scanf("%d",&k);
- int ans[k];
- i=0;
- char c;
- while(i<k){
- scanf(" %c",&c);
- if(c == 'P'){
- scanf("%d",&x);
- pq.push(x);
- }else if(c == 'Q'){
- if(pq.empty()){
- ans[ai] = -1;
- }
- else{
- ans[ai] = pq.top();
- pq.pop();
- }
- ai = ai + 1;
- }
- i = i + 1;
- }
- i = 0;
- while(i < ai){
- printf("%d\n",ans[i]);
- i = i + 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement