Pagini recente » Cod sursa (job #507873) | Cod sursa (job #385822) | Borderou de evaluare (job #1004060) | Cod sursa (job #2551865) | Cod sursa (job #3161819)
#include<fstream>
#include<queue>
using namespace std;
ifstream in ("heapuri.in");
ofstream out ("heapuri.out");
priority_queue <pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > heap,heap_eliminate;
int N, Value, Type, V[200005], Index, Nr;
int main (void) {
in >> N;
for (int i = 1; i <= N; i ++) {
in >> Type;
if (Type == 1) {
Nr ++;
in >> V[i];
heap.push({V[i],Nr});
}
if (Type == 2) {
in >> Index;
heap_eliminate.push({V[Index],Index});
while (heap_eliminate.size() > 0 && heap.top().second == heap_eliminate.top().second) {
heap.pop();
heap_eliminate.pop();
}
}
if (Type == 3) {
out <<heap.top().first <<"\n";
}
}
return 0;
}