Submission #336946

# Submission time Handle Problem Language Result Execution time Memory
336946 2020-12-17T12:56:21 Z BY_KUTBILIM Weighting stones (IZhO11_stones) C++14
100 / 100
288 ms 4588 KB
/** @BY_KUTBILIM **/
#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define ll long long

const int N = (int)1e6 + 12;

int mx[N], mn[N], add[N];

void push(int v, int l, int r){
    if(add[v] != 0){
        if(l != r){
            add[v*2] += add[v];
            add[v*2+1] += add[v];
        }
        mx[v] += add[v];
        mn[v] += add[v];
        add[v] = 0;
    }
}

void update(int v, int tl, int tr, int l, int r, int val){
    push(v, tl, tr);
    if(tr < l || tl > r)return ;
    if(l <= tl and tr <= r){
        add[v] += val;
        push(v, tl, tr);
        return ;
    }
    int tm = (tl + tr) / 2;
    update(v*2, tl, tm, l, r, val);
    update(v*2+1, tm+1, tr, l, r, val);
    mx[v] = max(mx[v*2], mx[v*2+1]);
    mn[v] = min(mn[v*2], mn[v*2+1]);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie();

    int n;
    cin >> n;
    int t = n;
    while(t--){
        int r, s;
        cin >> r >> s;
        if(s == 1){
            update(1, 1, n, 1, r, 1);
        } else{
            update(1, 1, n, 1, r, -1);
        }
        if(mx[1] >= 0 and mn[1] >= 0){
            cout << ">\n";
        } else if(mx[1] <= 0 and mn[1] <= 0){
            cout << "<\n";
        } else cout << "?\n";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 4 ms 364 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 25 ms 876 KB Output is correct
11 Correct 168 ms 2668 KB Output is correct
12 Correct 268 ms 4332 KB Output is correct
13 Correct 281 ms 4588 KB Output is correct
14 Correct 281 ms 4460 KB Output is correct
15 Correct 279 ms 4468 KB Output is correct
16 Correct 288 ms 4460 KB Output is correct
17 Correct 277 ms 4460 KB Output is correct
18 Correct 285 ms 4460 KB Output is correct
19 Correct 287 ms 4460 KB Output is correct
20 Correct 288 ms 4460 KB Output is correct
21 Correct 278 ms 4460 KB Output is correct
22 Correct 280 ms 4460 KB Output is correct
23 Correct 277 ms 4460 KB Output is correct
24 Correct 277 ms 4460 KB Output is correct
25 Correct 279 ms 4588 KB Output is correct