Submission #1046902

# Submission time Handle Problem Language Result Execution time Memory
1046902 2024-08-07T06:02:33 Z 12345678 Weighting stones (IZhO11_stones) C++17
100 / 100
42 ms 4680 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=1e5+5;

int n, x, t;

struct segtree
{
    int mn[4*nx], mx[4*nx], lz[4*nx];
    void pushlz(int l, int r, int i)
    {
        mn[i]+=lz[i];
        mx[i]+=lz[i];
        if (l!=r) lz[2*i]+=lz[i], lz[2*i+1]+=lz[i];
        lz[i]=0;
    }
    void update(int l, int r, int i, int ql, int qr, int vl)
    {
        pushlz(l, r, i);
        if (qr<l||r<ql) return;
        if (ql<=l&&r<=qr) return lz[i]+=vl, pushlz(l, r, i), void();
        int md=(l+r)/2;
        update(l, md, 2*i, ql, qr, vl);
        update(md+1, r, 2*i+1, ql, qr, vl);
        mn[i]=min(mn[2*i], mn[2*i+1]);
        mx[i]=max(mx[2*i], mx[2*i+1]);
    }
} s;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>x>>t;
        x=n-x+1;
        if (t==1) s.update(1, n, 1, x, n, 1);
        else s.update(1, n, 1, x, n, -1);
        if (s.mn[1]>=0) cout<<">\n";
        else if (s.mx[1]<=0) cout<<"<\n";
        else cout<<"?\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 860 KB Output is correct
11 Correct 25 ms 1880 KB Output is correct
12 Correct 33 ms 4156 KB Output is correct
13 Correct 24 ms 4492 KB Output is correct
14 Correct 25 ms 4380 KB Output is correct
15 Correct 28 ms 4432 KB Output is correct
16 Correct 25 ms 4440 KB Output is correct
17 Correct 25 ms 4680 KB Output is correct
18 Correct 25 ms 4320 KB Output is correct
19 Correct 27 ms 4436 KB Output is correct
20 Correct 26 ms 4444 KB Output is correct
21 Correct 26 ms 4436 KB Output is correct
22 Correct 25 ms 4364 KB Output is correct
23 Correct 42 ms 4480 KB Output is correct
24 Correct 25 ms 4432 KB Output is correct
25 Correct 28 ms 4432 KB Output is correct