Cod sursa(job #567469)

Utilizator gyeresihunorGyeresi Hunor gyeresihunor Data 30 martie 2011 08:56:35
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.55 kb
#include <stdio.h>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;

long n,i,j;
long a,b;
long t[200010];

set<long> st;

int main()
{
	freopen("heapuri.in","r",stdin);
	freopen("heapuri.out","w",stdout);
	
	scanf("%ld",&n);
	for(i=1,j=1;i<=n;i++)
	{
		scanf("%d",&a);
		switch (a)
		{
		case 1:
			scanf("%ld",&b);
			t[j]=b;
			j++;
			st.insert(b);
			break;
		case 2:
			scanf("%ld",&b);
			st.erase(t[b]);
			break;
		case 3:
			printf("%d\n",*(st.begin()));
			break;
		}
	}
	
	return 0;
}