Cod sursa(job #986388)

Utilizator StanAndreiAndrei Stan StanAndrei Data 18 august 2013 17:07:19
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.76 kb
#include <stdio.h>
#include <set>

#define NMAX 200005

using namespace std;

multiset<int> G;
int ORDER[NMAX],COUNT=0,N;

int main()
{
    freopen ("heapuri.in","r",stdin);
    freopen ("heapuri.out","w",stdout);

    scanf("%d\n",&N);

    int type,x,i;
    multiset<int>:: iterator it;
    for (i=1;i<=N;i++)
    {
        scanf("%d ",&type);
        if (type==1)
        {
            scanf("%d\n",&x);
            ORDER[++COUNT]=x;
            G.insert(x);
        }
        if (type==2)
        {
            scanf("%d\n",&x);
            G.erase(ORDER[x]);
        }
        if (type==3)
        {
            it=G.begin();
            printf("%d\n",*it);
        }
    }

    fclose(stdin);
    fclose(stdout);

    return 0;
}