Cod sursa(job #472380)

Utilizator andunhillMacarescu Sebastian andunhill Data 24 iulie 2010 13:30:36
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.49 kb
#include<fstream>
#include<set>
using namespace std;
#define nm 200001
ifstream f("heapuri.in");
ofstream g("heapuri.out");
int n,k,op,x;
int on[nm];
set<int>heap;
set<int>::iterator it;
int main()
{	f>>n;
	k=1;
	for(int i=1;i<=n;i++)
	{	f>>op;
		if(op==1)
		{	f>>x;
			heap.insert(x);
			on[k++]=x;
		}
		else
			if(op==2)
			{	f>>x;
				heap.erase(on[x]);
				on[x]=-1;
			}
			else
			{	it=heap.begin();
				g<<*it<<'\n';
			}
	}
	f.close();
	g.close();
	return 0;
}