Cod sursa(job #2845405)

Utilizator Theo14Ancuta Theodor Theo14 Data 7 februarie 2022 19:37:29
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.52 kb
#include<bits/stdc++.h>
using namespace std;

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

multiset<int>s;
int v[200002];

int main()
{
    int n,ok,x,i,k=0;
    f>>n;
    for(i=1;i<=n;i++)
    {
        f>>ok;
        if(ok==1)
        {
            f>>x;
            s.insert(x);
            k++;
            v[k]=x;
        }
        if(ok==2)
        {
            f>>x;
            s.erase(s.find(v[x]));
        }
        if(ok==3)
            g<<*s.begin()<<'\n';
    }
    return 0;
}