Cod sursa(job #430103)

Utilizator O_NealS. Alex O_Neal Data 30 martie 2010 19:06:22
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.5 kb
#include<cstdio>
#include<fstream>
#include<set>
using namespace std;

int main()
{
	multiset <int> h;
	int n,cod,x,poz[200001],kpoz=0;
	freopen("heapuri.out","w",stdout);
	ifstream fin("heapuri.in");
	fin>>n;
	for(int i=1; i<=n; ++i)
	{
		fin>>cod;
		if(cod==1) 
		{
			fin>>x;
			h.insert(x);
			poz[++kpoz]=x;
		}
		else if(cod==2)
		{
			fin>>x;
			h.erase(h.find(poz[x]));
		}
		else 
		{
			multiset <int> :: iterator it=h.begin();
			printf("%d\n", *it);
		}
	}
	return 0;
}