Advertisement
DontCallMeNuttoPleas

Machine

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