Cod sursa(job #2748626)

Utilizator witekIani Ispas witek Data 1 mai 2021 22:10:50
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.55 kb
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
using namespace std;

ifstream f("heapuri.in");
ofstream g("heapuri.out");

set <int> heap;
vector <int> v;

int n, op, x, y;

int main()
{
    f >> n;
    while(n--) {
        f >> op;
        if(op == 1) {
            f >> x;
            heap.insert(x);
            v.push_back(x);
        }
        else if(op == 2) {
            f >> x;
            heap.erase(v[x - 1]);
        }
        else {
            g << *(heap.begin()) << '\n';
        }
    }
}