Pagini recente » Cod sursa (job #2443787) | Cod sursa (job #499352) | Cod sursa (job #2899380) | Cod sursa (job #1690142) | Cod sursa (job #1921367)
#include <fstream>
#include <queue>
#include <bitset>
using namespace std;
ifstream f ("heapuri.in");
ofstream t ("heapuri.out");
struct integer{
int val,index;
bool operator <(const integer &aux) const{
return val>aux.val;
}
};
priority_queue <integer> heap;
bitset <200010> not_available;
int main()
{
int q,index=1;
f>>q;
for (int i=1,type,target;i<=q;++i){
f>>type;
if (type==1){
f>>target;
heap.push({target,index++});
continue;
}
if (type==2){
f>>target;
not_available[target]=true;
continue;
}
if (type==3){
while (not_available[(heap.top()).index])
heap.pop();
t<<(heap.top()).val<<'\n';
continue;
}
}
return 0;
}