Cod sursa(job #420235)

Utilizator BBchangBBchangh BBchang Data 18 martie 2010 17:51:03
Problema Heapuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.95 kb
#include<set>
#include<algorithm>
#include<cstdio>
#include<fstream>
using namespace std;
struct comp{
    bool operator()(long i,long j){
        return i<j;
    }
};
multiset<long,comp>heap;
//multiset<long>heap;
long N,pos[200005]={0};
//1:insert  2:delete  3:min
int main(){
    //freopen("heapuri.in","r",stdin);
    //freopen("heapuri.out","w",stdout);
    ifstream fin("heapuri.in");
    ofstream fout("heapuri.out");
    long t,k=0,x;
    //scanf("%d",&N);
    fin>>N;
    for(long i=1;i<=N;i++){
        //scanf("%ld",&t);
        fin>>t;
        if(t==1){
             //scanf("%ld",&x);
             fin>>x;
             heap.insert(x);
             pos[++k]=x;
        }
        if(t==2){
             //scanf("%ld",&x);
             fin>>x;
             heap.erase(pos[x]);
        }
        if(t==3){
           //printf("%ld\n",*heap.upper_bound(0));
           fout<<*heap.upper_bound(0);
        }
    }
return 0;}