Cod sursa(job #3216287)

Utilizator nicuhasCemartan Nicolae nicuhas Data 15 martie 2024 20:01:30
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.52 kb
#include <bits/stdc++.h>

using namespace std;
const int NMAX=2e5;
set <int> heap;
int n,k,poz[NMAX+1],i,x,a;
int main(){
    ifstream fin("heapuri.in");
    ofstream fout("heapuri.out");
    fin>>n;
    for(i=1;i<=n;i++){
        fin>>x;
        if(x==1){
            fin>>a;
            heap.insert(a);
            poz[++k]=a;
        }
        else if(x==2){
            fin>>a;
            heap.erase(poz[a]);
        }
        else{
            fout<<*heap.begin()<<"\n";
        }
    }
    return 0;
}