Cod sursa(job #2761172)

Utilizator MihaiBirsanMihai Birsan MihaiBirsan Data 30 iunie 2021 23:21:24
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.74 kb
#include <bits/stdc++.h>

using namespace std;

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


int n, cmd, x;
//int v[200001], heap[200001], poz[200001];
//vector<int> v;
//priority_queue <int, vector<int>, greater<int> > pq;
set<int> heap;

int main()
{

    //vector<int> v;
    vector<int> poz;

    fin >> n;
    for(int i = 1; i <= n; i++)
    {
        fin >> cmd ;;
        if(cmd == 1)
        {
            fin >> x;
            heap.insert(x);
            poz.push_back(x);
        }
        if(cmd == 2)
        {
            fin >> x;
            heap.erase(poz[x-1]);

        }
        if(cmd == 3)
        {
            fout << *(heap.begin()) << "\n";
        }
    }
    return 0;
}