Pagini recente » Cod sursa (job #3243106) | Cod sursa (job #2911786)
#include <fstream>
#define lsb(x) x & (-x)
#define int long long
using namespace std;
ifstream cin ("heapuri.in");
ofstream cout ("heapuri.out");
const int N = 2e5;
const int INF = 1e9 + 1;
int arb[4 * N], aib[N + 2];
struct punct
{
int cer, x;
} c;
int n;
void update (int nod, int l, int r, int pos, int val)
{
if (l == r)
{
arb[nod] = val;
return;
}
int mid = (l + r) >> 1;
if (pos <= mid) update ((nod << 1), l, mid, pos, val);
else update((nod << 1) + 1, mid + 1, r, pos, val);
arb[nod] = min (arb[(nod << 1)], arb[(nod << 1) + 1]);
}
void upgrade (int pos, int val)
{
for (int i = pos; i <= N; i += lsb(i))
aib[i] += val;
}
int query (int pos)
{
int s = 0;
for (int i = pos; i >= 1; i -= lsb(i))
s += aib[i];
return s;
}
signed main()
{
int k = 1;
for (int i = 1; i <= 4 * N; ++i)
arb[i] = INF;
for (cin >> n; n; --n)
{
cin >> c.cer;
if (c.cer == 1)
{
cin >> c.x;
update (1, 1, N, k, c.x);
++k;
}
else if (c.cer == 2)
{
cin >> c.x;
//upgrade (c.x, 1);
//int u = query (c.x);
update (1, 1, N, c.x, INF);
}
else
{
cout << arb[1] << '\n';
}
}
return 0;
}