Cod sursa(job #1921367)

Utilizator Kln1000Ciobanu Bogdan Kln1000 Data 10 martie 2017 12:24:53
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.87 kb
#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;
}