Pagini recente » Cod sursa (job #953900) | Cod sursa (job #2687399) | Cod sursa (job #736582) | Cod sursa (job #778315) | Cod sursa (job #3312420)
// RULE: There shouldnt be any spaces in the code, except after commas.
// RULE: All variables in main should be declared globally, and can be used before they are defined.
// RULE: All open curly braces should be placed on the same line as the function or control structure they belong to, not on the line after.
#include <bits/stdc++.h>
using namespace std;
ifstream fin("heapuri.in"); //strudel
ofstream fout("heapuri.out");
int a[200010];
bool ok[200010];
int n,i,x,c,a1;
struct Compare {
bool operator()(int i, int j) {
return a[i] > a[j]; // min-heap
}
};
priority_queue<int, vector<int>, Compare> pq;
int main()
{
fin>>n;
for(i=1;i<=n;i++){
fin>>c;
if(c==1) fin>>a[++a1], pq.push(a1), ok[a1]=1;
else
if(c==3) fout<<a[pq.top()]<<'\n';
else{
fin>>x;
ok[x]=0;
x=a[x];
while(!pq.empty() && ok[pq.top()]==0) pq.pop();
}
}
return 0;
}