# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092117 | juicy | Weighting stones (IZhO11_stones) | C++17 | 27 ms | 4460 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;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 1e5 + 5;
int n;
int s[4 * N], mn[4 * N], mx[4 * N];
void upd(int i, int x, int id = 1, int l = 1, int r = n) {
if (l == r) {
s[id] = mn[id] = mx[id] = x;
return;
}
int m = (l + r) / 2;
if (i <= m) {
upd(i, x, id * 2, l, m);
} else {
upd(i, x, id * 2 + 1, m + 1, r);
}
s[id] = s[id * 2] + s[id * 2 + 1];
mn[id] = min(mn[id * 2] + s[id * 2 + 1], mn[id * 2 + 1]);
mx[id] = max(mx[id * 2] + s[id * 2 + 1], mx[id * 2 + 1]);
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n;
for (int i = 0; i < n; ++i) {
int r, s; cin >> r >> s;
upd(r, s == 1 ? 1 : -1);
cout << (mx[1] <= 0 ? '<' : (mn[1] >= 0 ? '>' : '?')) << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |