# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
336101 | nikatamliani | Weighting stones (IZhO11_stones) | C++14 | 0 ms | 0 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>
#define mn first
#define mx second
using namespace std;
const int N = 1e5+10;
pair<int,int> tree[4*N];
int lazy[4*N];
void push(int l, int r, int p) {
if(l < r) {
lazy[p << 1] += lazy[p];
lazy[p << 1 | 1] += lazy[p];
}
tree[p].mn += lazy[p];
tree[p].mx += lazy[p];
lazy[p] = 0;
}
void add(int l, int r, int L, int R, int val, int p) {
push(l, r, p);
if(l > R || L > r) return;
if(L <= l && R >= r) {
lazy[p] += val;
push(l, r, p);
} else {
int m = l + r >> 1;
add(l, m, L, R, val, p << 1);
add(m+1, r, L, R, val, p << 1 | 1);
tree[p].mn = min(tree[p << 1].mn, tree[p << 1 | 1].mn);
tree[p].mx = max(tree[p << 1].mx, tree[p << 1 | 1].mx);
}
}
int main() {
int n;
cin >> n;
for(int i = 1; i <= n; ++i) {
int x, where;
cin >> x >> where;
if(where == 1) {
add(1, n, 1, x, 1, 1);
} else {
add(1, n, 1, x, -1, 1);
}
if(tree[1].mn >= 0) {
cout << ">\n";
} else if(tree[1].mx <= 0) {
cout << "<\n";
} else {
cout << "?\n";
}
}