We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<bits/stdc++.h>#define lli long long intusingnamespacestd;structgreaters{booloperator()(constlong&a,constlong&b)const{returna>b;}};intmain(intargc,char*argv[]){ios_base::sync_with_stdio(false);cin.tie(NULL);vector<int>v;llitc;cin>>tc;while(tc--){llix;cin>>x;if(x==1){// insertllival;cin>>val;v.push_back(val);push_heap(v.begin(),v.end(),greaters());}elseif(x==2){// delete specific nodellival;cin>>val;autoit=find(v.begin(),v.end(),val);boolisFound=it!=v.end();if(isFound){swap(*it,v.back());v.pop_back();make_heap(v.begin(),v.end(),greaters());}}else{// print minimum heapcout<<v.front()<<"\n";}}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
QHEAP1
You are viewing a single comment's thread. Return to all comments →