Submission #523189

# Submission time Handle Problem Language Result Execution time Memory
523189 2022-02-07T07:28:18 Z redstonegamer22 Weighting stones (IZhO11_stones) C++17
100 / 100
239 ms 3704 KB
#include <bits/stdc++.h>

using namespace std;

const int offset = (1 << 17);
const int NMAX = 100000 + 7;

int lazy[2 * offset], maxs[2 * offset], mins[2 * offset];

void push_lazy(int node) {
    maxs[node] += lazy[node];
    mins[node] += lazy[node];

    if(node < offset) {
        lazy[2 * node] += lazy[node];
        lazy[2 * node + 1] += lazy[node];
    }

    lazy[node] = 0;
}

void update(int node, int l, int r, int gl, int gr, int upd) {
    push_lazy(node);
    if(r < gl || gr < l) return;

    if(gl <= l && r <= gr) {
        lazy[node] += upd;
        push_lazy(node);
        return;
    }

    int mid = (l + r) / 2;
    update(2 * node, l, mid, gl, gr, upd);
    update(2 * node + 1, mid + 1, r, gl, gr, upd);

    maxs[node] = max(maxs[2 * node], maxs[2 * node + 1]);
    mins[node] = min(mins[2 * node], mins[2 * node + 1]);

    return;
}

int main()
{
    assert(offset > NMAX);

    int n; cin >> n;

    for(int i = 0; i < n; i++) {
        int x, s; cin >> x >> s;
        if(s == 1) update(1, 0, offset - 1, 0, x, +1);
        else update(1, 0, offset - 1, 0, x, -1);

#ifdef LOCAL
        cerr << '\t' << maxs[1] << " " << mins[1] << endl;
#endif // LOCAL

        if(maxs[1] > 0 && mins[1] < 0) cout << '?' << endl;
        else if(maxs[1] > 0) cout << '>' << endl;
        else cout << '<' << endl;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 3 ms 332 KB Output is correct
9 Correct 4 ms 332 KB Output is correct
10 Correct 18 ms 588 KB Output is correct
11 Correct 124 ms 2224 KB Output is correct
12 Correct 209 ms 3312 KB Output is correct
13 Correct 239 ms 3564 KB Output is correct
14 Correct 215 ms 3596 KB Output is correct
15 Correct 197 ms 3668 KB Output is correct
16 Correct 209 ms 3660 KB Output is correct
17 Correct 236 ms 3672 KB Output is correct
18 Correct 222 ms 3636 KB Output is correct
19 Correct 195 ms 3636 KB Output is correct
20 Correct 194 ms 3652 KB Output is correct
21 Correct 186 ms 3680 KB Output is correct
22 Correct 196 ms 3704 KB Output is correct
23 Correct 195 ms 3640 KB Output is correct
24 Correct 195 ms 3608 KB Output is correct
25 Correct 222 ms 3588 KB Output is correct