Cod sursa(job #2445461)

Utilizator Mihai145Oprea Mihai Adrian Mihai145 Data 4 august 2019 10:06:35
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.59 kb
#include <fstream>
#include <vector>
#include <set>

using namespace std;

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

int N;
set <int> s;
vector <int> ins;

int main()
{
    fin >> N;

    for(int i = 1; i <= N; i++)
    {
        int t;
        fin >> t;

        if(t == 3)
            fout << *s.begin() << '\n';
        else if(t == 2)
        {
            int x;
            fin >> x;
            s.erase(ins[x - 1]);
        }
        else
        {
            int x;
            fin >> x;
            s.insert(x);
            ins.push_back(x);
        }
    }

    return 0;
}