Cod sursa(job #2906403)

Utilizator David_PatranjelDavid Patranjel David_Patranjel Data 25 mai 2022 23:24:19
Problema Heapuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.75 kb
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <set>

using namespace std;

set<int> s;
unordered_map<int,int> h;

int main()
{
    ifstream fin("heapuri.in");
    ofstream fout("heapuri.out");
    int ops,cs,nr,k = 0;
    fin>>ops;
    for(int i=1;i<=ops;i++){
        fin>>cs;
        switch(cs){
        case 1:{
            k++;
            fin>>nr;
            h[k] = nr;
            s.insert(nr);
            break;
        }
        case 2:{
            fin>>nr;
            int x = h[nr];
            s.erase(x);
            break;
        }
        case 3:{
            cout<<*s.begin()<<endl;
            break;
        }
        }
    }
    fin.close();
    fout.close();
    return 0;
}