Cod sursa(job #516904)

Utilizator brainwashed20Alexandru Gherghe brainwashed20 Data 26 decembrie 2010 22:24:17
Problema Heapuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.47 kb
#include <cstdio>
#include <set>

#define Nmax 200100

using namespace std;

int Poz[Nmax], L;
multiset <int> S;

int main () {
	freopen("heapuri.in","r",stdin);
	freopen("heapuri.out","w",stdout);

	int N, tip, x;
	
	for(scanf("%d",&N); N; --N) {
		scanf("%d", &tip);
		if(tip<3)
			scanf("%d",&x);
		if(tip==1) {
			S.insert(x);
			Poz[++L]=x;
		} 
		else 
			if(tip==2) {
				S.erase(S.find(Poz[x]));
			}
			else
				printf("%d\n",*S.begin());
	}
}