Cod sursa(job #1314684)

Utilizator goalexboxerFMI Alexandru Ionascu goalexboxer Data 12 ianuarie 2015 10:02:39
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.88 kb
#include<stdio.h>
#include<set>
#define FIN "heapuri.in"
#define FOUT "heapuri.out"
#define MAXSIZE 100002
using namespace std;

multiset<int> heap;
int position[MAXSIZE];
int order = 1;
int n;


int main()
{
    freopen(FIN, "r", stdin);
    freopen(FOUT, "w", stdout);

    scanf("%d ", &n);

    for(int i=1;i<=n;i++)
    {
        int x,y;

        scanf("%d ", &x);
        if(x == 1)
        {
            scanf("%d ", &y);
            heap.insert(y);
            position[order] = y;
            order++;
        }
        else if(x == 2)
        {
            scanf("%d ", &y);

            heap.erase(position[y]);
        }
        else
        {
            //printf("%d \n", heap.begin());
           // for(multiset<int>::iterator it=heap.begin(); it!=heap.end(); it++)
            //    printf("%d ", *it);
            printf("%d \n", *heap.begin());
        }
    }

    return 0;

}