Pagini recente » Cod sursa (job #442372) | Cod sursa (job #2633531) | Cod sursa (job #2182687) | Cod sursa (job #2885248) | Cod sursa (job #1318698)
#include <cstdio>
#include <set>
#define nmax 200010
using namespace std;
FILE *f1=fopen("heapuri.in","r"),*f2=fopen("heapuri.out","w");
multiset <int> heap;
int n,tmp[nmax],nr;
int main()
{
fscanf(f1,"%d",&n);
for(int i=1;i<=n;i++)
{
int opt;
fscanf(f1,"%d",&opt);
if(opt==1)
{
int x;
fscanf(f1,"%d",&x);
tmp[++nr]=x;
heap.insert(x);
}
else if(opt==2)
{
int x;
fscanf(f1,"%d",&x);
heap.erase(tmp[x]);
}
else
fprintf(f2,"%d\n",*heap.begin());
}
fclose(f1);
fclose(f2);
return 0;
}
//Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time.