Cod sursa(job #2263278)

Utilizator alexge50alexX AleX alexge50 Data 18 octombrie 2018 16:01:06
Problema Heapuri Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.64 kb
#include <fstream>
#include <vector>
#include <set>
#include <functional>

int main()
{
    std::ifstream fin("heapuri.in");
    std::ofstream fout("heapuri.out");
    int n;
    std::set<int> s;
    std::vector<int> history;

    fin >> n;
    int x;
    int c;
    for(int i = 0; i < n; i++)
    {
        fin >> c;

        if(c == 1)
        {
            fin >> x;

            s.insert(x);
            history.push_back(x);
        }
        else if (c == 2)
        {
            fin >> x;

            s.erase(history[x - 1]);
        }
        else if (c == 3)
        {
            fout << *s.begin() << std::endl;
        }
    }

    return 0;
}