MAGCARI

Lightest

Aug 9th, 2022
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. /*
  2.     Task    : Lightest
  3.     Author  : Phumipat C. [MAGCARI]
  4.     Language: C++
  5.     Created : 09 August 2022 [18:48]
  6. */
  7. #include<bits/stdc++.h>
  8. using namespace std;
  9. struct A{
  10.     int v,w;
  11.     bool operator < (const A&o) const{
  12.         return w>o.w;
  13.     }
  14. };
  15. priority_queue<A > heap;
  16. int main(){
  17.     cin.tie(0)->sync_with_stdio(0);
  18.     cin.exceptions(cin.failbit);
  19.     int n,m,w,v;
  20.     char opr;
  21.     cin >> n >> m;
  22.     n+=m;
  23.     while(n--){
  24.         cin >> opr;
  25.         if(opr == 'T'){
  26.             cin >> w >> v;
  27.             heap.push({v,w});
  28.         }else{
  29.             if(heap.empty()){
  30.                 cout << "0\n";
  31.             }else{
  32.                 A now = heap.top();
  33.                 heap.pop();
  34.                 cout << now.v << '\n';
  35.             }
  36.         }
  37.     }
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment