Cod sursa(job #547267)

Utilizator skullLepadat Mihai-Alexandru skull Data 6 martie 2011 08:42:14
Problema Heapuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.49 kb
#include <stdio.h>
#include <set>
using namespace std;
#define nmax 200005

multiset<int> A;
int poz[nmax];
int N, nr;

int main ()
{
	int i, tip, x;
	freopen("heapuri.in","r",stdin);
	freopen("heapuri.out","w",stdout);
	scanf("%d", &N);
	for (i = 1; i <= N; ++i)
	{
		scanf("%d", &tip);
		if (tip == 1) { scanf("%d", &x); A.insert(x); poz[++nr] = x; }
			else if (tip == 2) { scanf("%d", &x); A.erase( A.find(poz[x]) ); }
				else printf("%d\n", *A.begin());
	}
	return 0;
}