Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Task : Lightest
- Author : Phumipat C. [MAGCARI]
- Language: C++
- Created : 09 August 2022 [18:48]
- */
- #include<bits/stdc++.h>
- using namespace std;
- struct A{
- int v,w;
- bool operator < (const A&o) const{
- return w>o.w;
- }
- };
- priority_queue<A > heap;
- int main(){
- cin.tie(0)->sync_with_stdio(0);
- cin.exceptions(cin.failbit);
- int n,m,w,v;
- char opr;
- cin >> n >> m;
- n+=m;
- while(n--){
- cin >> opr;
- if(opr == 'T'){
- cin >> w >> v;
- heap.push({v,w});
- }else{
- if(heap.empty()){
- cout << "0\n";
- }else{
- A now = heap.top();
- heap.pop();
- cout << now.v << '\n';
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment