Advertisement
YEZAELP

PROG-1021: Machine

Jun 7th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4.  
  5.     int n;
  6.     scanf("%d",&n);
  7.     priority_queue <int> pq;
  8.     for(int i=0;i<n;i++){
  9.         char a;
  10.         scanf(" %c",&a);
  11.         if(a=='P'){
  12.             int x;
  13.             scanf("%d",&x);
  14.             pq.push(x);
  15.         }
  16.         else {
  17.             if(pq.empty()) printf("-1");
  18.             else{
  19.                 printf("%d",pq.top());
  20.                 pq.pop();
  21.             }
  22.             printf("\n");
  23.         }
  24.     }
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement