Cod sursa(job #480711)

Utilizator andrei.dAndrei Diaconeasa andrei.d Data 29 august 2010 12:33:48
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.01 kb
#include <cstdio>
#include <set>
//#include <ctime>

using namespace std;

#define file_in "heapuri.in"
#define file_out "heapuri.out"

//long long my_time;
int T;
int cnt[1<<18];
multiset<int> H;

#define dim 8192

char a[dim];
int p;

inline void citire(int &x)
{
	x=0;
	while(a[p]<'0' || a[p]>'9')
		if(++p==dim) 
			fread(a,1,dim,stdin),p=0;
	while(a[p]>='0' && a[p]<='9')
	{
		x=x*10+a[p]-'0';
		if(++p==dim)
			fread(a,1,dim,stdin),p=0;
	}
}


void adfile()
{
	freopen(file_in,"r",stdin);
	freopen(file_out,"w",stdout);
	
	citire(T);

}

void solve()
{
	int tip,x,nr=0;
	while(T--)
	{
		citire(tip);
		if (tip!=3) citire(x);
		if (tip==1)
		{
			cnt[++nr]=x;
			H.insert(x);
		}
		if (tip==2)
        {
			H.erase(H.find(cnt[x]));
		}
		if (tip==3)
			printf("%d\n", *H.begin());
	}
	
	//printf ("Solution ended in %.4lf\n",(double)((double)clock()-my_time)/CLOCKS_PER_SEC); 
}

int main()
{
	//my_time=clock();
	adfile();
	solve();

	return 0;
	
}