Cod sursa(job #2906411)

Utilizator David_PatranjelDavid Patranjel David_Patranjel Data 25 mai 2022 23:43:03
Problema Heapuri Scor 40
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 ops,cs;
long nr,k = 0;
int main()
{
    ifstream fin("heapuri.in");
    ofstream fout("heapuri.out");
    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:{
            fout<<*s.begin()<<endl;
            break;
        }
        }
    }
    fin.close();
    fout.close();
    return 0;
}