Cod sursa(job #1624971)

Utilizator teodor440Teodor Tonghioiu teodor440 Data 2 martie 2016 15:35:43
Problema Heapuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.59 kb
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <algorithm>

using namespace std;

ifstream f("heapuri.in");
ofstream g("heapuri.out");

set<int> heap;
int elem[300000];
int n;

int main()
{
	int i, j, comm, val, k;
	k = 1;
	f >> n;
	for (i = 1; i <= n; i++) {
		f >> comm;
		switch (comm) {
		case 1:
			f >> val;
			elem[k++] = val;
			heap.insert(val);
			break;
		case 2:
			f >> val;
			heap.erase(heap.find(elem[val]));
			break;
		case 3:
			g << *heap.begin();
			break;
		}
	}

	return 0;
}