Pagini recente » Cod sursa (job #2260249) | Cod sursa (job #1115949) | Cod sursa (job #514918) | Cod sursa (job #1005418) | Cod sursa (job #2833890)
#include <fstream>
#include <queue>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
typedef pair < int, int > PII;
const int NMAX = 2e5 + 1;
int Q;
int N, ids;
bool Deactivated[NMAX];
auto cmp = [] (PII A, PII B)
{
if(!(A.first < B.first))
return 1;
return 0;
};
priority_queue < PII, vector < PII >, decltype(cmp) > H(cmp);
int main()
{
f.tie(nullptr);
f >> Q;
while(Q--)
{
short int _type = 0;
f >> _type;
if(_type == 1)
{
int X = 0;
f >> X;
H.push({X, ++ids});
continue;
}
if(_type == 2)
{
int Id = 0;
f >> Id;
Deactivated[Id] = 1;
continue;
}
while(!H.empty() && Deactivated[H.top().second])
H.pop();
if(!H.empty())
g << H.top().first << '\n';
}
return 0;
}