Cod sursa(job #2893159)
Utilizator | Data | 25 aprilie 2022 12:58:20 | |
---|---|---|---|
Problema | Heapuri | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.85 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f ("heapuri.in");
ofstream g ("heapuri.out");
int h[200001];
int ord[200001], n, o, op, a;
int main()
{
f>>n;
for ( int i = 1; i <= n; i++ )
{
f>>op;
if ( op==1 )
{
f>>a;
h[i]=a;
o++;
ord[o]=a;
}
else if (op==2)
{
f>>a;
h[i]=0;
}
else
{
int idx=-1;
int minim=99999;
for(int i=1; i<=200001;i++)
if(minim>h[i]&&h[i]!=0)
{minim=h[i];
idx=i;
}
g<<minim;
g<<"\n";
h[idx]=0;
}
}
return 0;
}