Cod sursa(job #539430)

Utilizator Rares95Rares Arnautu Rares95 Data 22 februarie 2011 22:28:45
Problema Heapuri Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.49 kb
# include <cstdio>
# include <set>
# define max 200001
# define open_files freopen("heapuri.in","r",stdin); freopen("heapuri.out","w",stdout)
  using namespace std;
  int poz[max], m, n, tip, x;
	set <int> rares;
	int main ()
	{	open_files;
		for (scanf ("%d%d", &n, &tip); n; --n, scanf ("%d", &tip)) 
		{	if(tip<3) scanf("%d",&x);
			if(tip==1) {rares.insert(x); poz[++m]=x;} 
			else if(tip==2) rares.erase(rares.find(poz[x]));
						else printf("%d\n",*rares.begin());
		}
		return 0;
	}