Cod sursa(job #2567140)

Utilizator viftode4Iftode Vlad viftode4 Data 3 martie 2020 15:26:07
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.97 kb
#include <bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
ifstream fin( "heapuri.in" );
ofstream fout( "heapuri.out" );
void fast()
{
    cin.tie( 0 );
    ios_base::sync_with_stdio( 0 );
}
int n;
multiset<int>heap;
int ord[200005], k;
int main()
{
    fast();
    fin >> n;

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

            if( t == 3 )
                fout << *heap.begin() << '\n';
            else
                {
                    int x;
                    fin >> x;

                    if( t == 1 )
                        {
                            k++;
                            ord[k] = x;
                            heap.insert( x );
                        }
                    else
                        heap.erase( heap.find( ord[x] ) );
                }
        }

    return 0;
}