Cod sursa(job #1396544)
Utilizator | Sergiu Nasca sergiunasca | Data | 22 martie 2015 17:47:50 |
---|---|---|---|
Problema | Heapuri | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.71 kb |
#include <stdio.h>
#include <vector>
#include <algorithm>
#define INF (1<<30)
using namespace std;
std::vector< int > a,b;
int n,x,y;
bool CMP(int A,int B)
{
return A>B;
}
int main()
{
freopen("heapuri.in","r",stdin);
freopen("heapuri.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
scanf("%d",&x);
if(x==1)
{
scanf("%d",&y);
a.push_back(y);
}
else if(x==2)
{
scanf("%d",&y);
a[y-1] = INF;
}
else
{
b = a;
std::make_heap(b.begin(),b.end(),CMP);
printf("%d\n",b[0]);
}
}
return 0;
}