Submission #894968

# Submission time Handle Problem Language Result Execution time Memory
894968 2023-12-29T09:57:14 Z Andrey Weighting stones (IZhO11_stones) C++14
100 / 100
42 ms 7264 KB
#include<bits/stdc++.h>
using namespace std;

vector<int> sm(500001);
vector<int> big(500001);
vector<int> wow(500001);

void upd(int l, int r, int ql, int qr, int x, int a) {
    if(l == ql && r == qr) {
        sm[x]+=a;
        big[x]+=a;
        wow[x]+=a;
        return;
    }
    int m = (l+r)/2;
    if(qr <= m) {
        upd(l,m,ql,qr,x*2,a);
    }
    else if(ql > m) {
        upd(m+1,r,ql,qr,x*2+1,a);
    }
    else {
        upd(l,m,ql,m,x*2,a);
        upd(m+1,r,m+1,qr,x*2+1,a);
    }
    big[x] = max(big[x*2],big[x*2+1])+wow[x];
    sm[x] = min(sm[x*2],sm[x*2+1])+wow[x];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,a,b;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a >> b;
        a = n-a+1;
        if(b == 1) {
            upd(1,n,a,n,1,1);
        }
        else {
            upd(1,n,a,n,1,-1);
        }
        if(sm[1] >= 0) {
            cout << ">\n";
        }
        else if(big[1] <= 0) {
            cout << "<\n";
        }
        else {
            cout << "?\n";
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6236 KB Output is correct
2 Correct 2 ms 6200 KB Output is correct
3 Correct 2 ms 6352 KB Output is correct
4 Correct 2 ms 6248 KB Output is correct
5 Correct 3 ms 6352 KB Output is correct
6 Correct 3 ms 6232 KB Output is correct
7 Correct 3 ms 6236 KB Output is correct
8 Correct 3 ms 6236 KB Output is correct
9 Correct 3 ms 6236 KB Output is correct
10 Correct 7 ms 6564 KB Output is correct
11 Correct 22 ms 6744 KB Output is correct
12 Correct 34 ms 7120 KB Output is correct
13 Correct 31 ms 7256 KB Output is correct
14 Correct 31 ms 7252 KB Output is correct
15 Correct 33 ms 7108 KB Output is correct
16 Correct 33 ms 7260 KB Output is correct
17 Correct 32 ms 7264 KB Output is correct
18 Correct 33 ms 7256 KB Output is correct
19 Correct 42 ms 7256 KB Output is correct
20 Correct 32 ms 7172 KB Output is correct
21 Correct 33 ms 7260 KB Output is correct
22 Correct 33 ms 7052 KB Output is correct
23 Correct 32 ms 7248 KB Output is correct
24 Correct 33 ms 7104 KB Output is correct
25 Correct 33 ms 7260 KB Output is correct