Cod sursa(job #1732494)

Utilizator codebreaker24Tivadar Ionut codebreaker24 Data 21 iulie 2016 18:51:59
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.72 kb
#include<iostream>
#include<fstream>
#include<set>

using namespace std;

const int NMAX = 200001;
multiset <int> heap;

int chrono[NMAX];

int n;
int type;
int value;
int k = 0;
int main ()
{
    ifstream fin("heapuri.in");
    ofstream fout("heapuri.out");

    fin >> n;

    for(int i=0; i<n; i++)
    {
       fin >> type;
       if(type == 1)
       {

           fin >> value;
           chrono[++k]=value;
           heap.insert(value);
       }
       if(type == 2)
       {

           fin >> value;
           heap.erase(chrono[value]);

       }
       if(type == 3)
       {

          fout << *heap.begin() << '\n';
       }
    }

    fin.close();
    fout.close();

}