Cod sursa(job #1049898)

Utilizator Dayanna000Amegica Dayanna Dayanna000 Data 7 decembrie 2013 22:04:49
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.72 kb
#include <iostream>
#include <fstream>
#include <set>
using namespace std;
set <int> heap;
set <int>::iterator it;
int main()
{
    ifstream f("heapuri.in");
    ofstream g("heapuri.out");
    int n,cod,x,i,elem[200006],nr=0;
    f>>n;
    for(i=1;i<=n;++i)
      {
          f>>cod;
          if(cod==1)
            {
                f>>x;
                heap.insert(x);
                nr++;
                elem[nr]=x;
            }
            else
          if(cod==2)
            {
                f>>x;
                heap.erase(elem[x]);
            }
            else
            {
                it=heap.begin();
                g<<*it<<'\n';
            }
      }
    f.close();
    g.close();
    return 0;
}