Pagini recente » Cod sursa (job #2040672) | Cod sursa (job #1341098) | Cod sursa (job #1974589) | Cod sursa (job #1557129) | Cod sursa (job #1983318)
#include <fstream>
#include <queue>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
const int nmax=200000;
int v[nmax+1];
struct cmp {
bool operator () (const int &x, const int &y) {
return x>y;
}
};
priority_queue <int, vector<int>, cmp> h, hd;
int main () {
int n;
fin>>n;
int aux=1;
for (int i=1; i<=n; i++) {
int x;
fin>>x;
if (x==1) {
int y;
fin>>y;
h.push(y);
v[aux]=y;
aux++;
} else if (x==2) {
int y;
fin>>y;
hd.push(v[y]);
} else {
while (hd.empty()==0 && hd.top()==h.top()) {
h.pop();
hd.pop();
}
fout<<h.top()<<"\n";
}
}
return 0;
}