Cod sursa(job #3124199)
Utilizator | Data | 27 aprilie 2023 11:11:48 | |
---|---|---|---|
Problema | Heapuri | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.65 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
unordered_map<int, int> m;
set<int> s;
int n,v[200001],c;
int main()
{int i,k=0,x;
f>>n;
for (i=1;i<=n;i++)
{
f>>c;
if (c==1)
{
f>>x;
m[x]++;
k++;
v[k]=x;
if (m[x]==1)
s.insert(x);
}
if (c==2)
{
f>>x;
m[v[x]]--;
if (m[v[x]]==0)
s.erase(v[x]);
}
if (c==3)
{
g<<*s.begin()<<'\n';
}
}
}