Cod sursa(job #2517132)
| Utilizator | Data | 2 ianuarie 2020 22:05:44 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.83 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("heapuri.in");
ofstream out("heapuri.out");
int n;
int a[200001],vf;
priority_queue <int,vector<int>,greater<int>> c;
map <int,int> elim;
int main()
{
in>>n;
int q,nr;
for(int i=1;i<=n;i++)
{
in>>q;
switch(q)
{
case 1:
in>>nr;
a[++vf]=nr;
c.push(nr);
break;
case 2:
in>>nr;
elim[ a[nr] ]++;
break;
case 3:
while( elim[ c.top() ] )
{
elim[ c.top() ]--;
c.pop();
}
out<<c.top()<<'\n';
break;
}
}
return 0;
}
