Cod sursa(job #3347796)

Utilizator moloDaniMolodet Andrei Daniel moloDani Data 18 martie 2026 13:23:26
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.7 kb
#include <fstream>
#include <queue>

using namespace std;

ifstream fin ("heapuri.in");
ofstream fout ("heapuri.out");

const int mxN = 2e5 + 1;

struct nod{
    int v, ind;
};

bool operator<(nod a, nod b){
    return a.v > b.v;
}

priority_queue<nod> Q;
bool del[mxN];

int main(){
    int n, q, v, ind = 0, aux;
    fin >> n;

    for(int i = 1 ; i <= n; i++){
        fin >> q;
        if(q == 3){
            while(del[Q.top().ind])
                Q.pop();
            fout << Q.top().v << "\n";
        }else{
            if(q == 1){
                fin >> aux;
                Q.push({aux, ++ind});
            }else{
                fin >> v;
                del[v] = true;
            }
        }
    }
}