Cod sursa(job #480710)

Utilizator andrei.dAndrei Diaconeasa andrei.d Data 29 august 2010 12:20:44
Problema Heapuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.67 kb
#include <cstdio>
#include <set>

using namespace std;

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

int T;
int cnt[1<<18];
int nr=0;
multiset<int> H;

inline void adfile()
{
	freopen(file_in,"r",stdin);
	freopen(file_out,"w",stdout);
	
	scanf("%d", &T);

}

inline void solve()
{
	int tip,x;
	for (int i=1;i<=T;++i)
	{
		scanf("%d", &tip);
		if (tip!=3) scanf("%d", &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());
	}
}

int main()
{
	adfile();
	solve();
	
	fclose(stdin);
	fclose(stdout);

	return 0;
	
}