Cod sursa(job #402593)

Utilizator toni2007Pripoae Teodor Anton toni2007 Data 23 februarie 2010 23:21:08
Problema Heapuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.47 kb
#include <cstdio>
#include <set>

#define maxN 200100

using namespace std;

int Poz[maxN], N, Nr;
multiset <int> S;

int main () {
	int tip, x;

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

	scanf("%d", &N);

	for ( ; N -- ; ) {
		scanf("%u", &tip);

		if (tip < 3)
			scanf("%u", &x);

		if (tip == 1) {
			S.insert(x);
			Poz[ ++ Nr] = x;
		} else if (tip == 2){
            S.erase(S.find(Poz[x]));
		} else
			printf("%d\n", *(S.begin ()));
	}
}