Cod sursa(job #412589)

Utilizator xtephanFodor Stefan xtephan Data 5 martie 2010 20:17:09
Problema Heapuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.81 kb
#include<fstream>
#include<set>

using namespace std;

struct comp {
	
	bool operator()(int i, int j) {
		return i<j;
	}
	
};


multiset<int,comp> heap;
int N;
int poz[40002];

int main() {
	
	int t,k=0,x;
	
	/*
	freopen("heapuri.in", "r", stdin);
	freopen("heapuri.out", "w", stdout);
	
	scanf("%d",&N);
	*/
	
	ifstream fin("heapuri.in");
	ofstream fout("heapuri.out");
	
	fin>>N;
	
	for(int i=1; i<=N;i++) {
		
		//scanf("%d",&t);
		fin>>t;
		if(t==1) {
			//scanf("%d",&x);
			fin>>x;
			heap.insert(x);
			poz[++k]=x;
		}
		
		if(t==2) {
			//scanf("%d",&x);
			fin>>x;
			heap.erase(poz[x]);
		}
		
		
		if(t==3) {
			//x=*heap.upper_bound(0);
			//printf("%d\n",x);
			fout<<*heap.upper_bound(0)<<"\n";
		}
	}
	
	
	fin.close();
	fout.close();
	
	return 0;
}