# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1113410 | Chinguun | Weighting stones (IZhO11_stones) | C++14 | 34 ms | 7676 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define meta int m = (L + R) / 2, x = i * 2 + 1, y = x + 1
const int N = 4e5 + 7;
int s[N], mx[N], mn[N];
void update (int i, int L, int R, int k, int v) {
if (L == R) {
s[i] = mx[i] = mn[i] = v;
return;
}
meta;
if (k <= m) update (x, L, m, k, v);
else update (y, m + 1, R, k, v);
s[i] = s[x] + s[y];
mn[i] = min (mn[x] + s[y], mn[y]);
mx[i] = max (mx[x] + s[y], mx[y]);
return;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n; cin >> n;
for (int i = 1; i <= n; i++) {
int x, y; cin >> x >> y; x--;
if (y == 1) update (0, 0, n - 1, x, 1);
else update (0, 0, n - 1, x, -1);
if (mx[0] <= 0) cout << '<';
else if (mn[0] >= 0) cout << '>';
else cout << '?';
cout << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |