Submission #764541

# Submission time Handle Problem Language Result Execution time Memory
764541 2023-06-23T14:47:58 Z Trunkty Weighting stones (IZhO11_stones) C++14
100 / 100
38 ms 7456 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

int n;

//

int sumi[400020],maxi[400020],mini[400020];

void update(int node, int l, int r, int pos, int val){
    if(l==r){
        sumi[node] = val;
        maxi[node] = val;
        mini[node] = val;
    }
    else{
        int mid = (l+r)/2;
        if(pos<=mid){
            update(node*2,l,mid,pos,val);
        }
        else{
            update(node*2+1,mid+1,r,pos,val);
        }
        sumi[node] = sumi[node*2]+sumi[node*2+1];
        mini[node] = min(mini[node*2+1],mini[node*2]+sumi[node*2+1]);
        maxi[node] = max(maxi[node*2+1],maxi[node*2]+sumi[node*2+1]);
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i=1;i<=n;i++){
        int a,b;
        cin >> a >> b;
        if(b==1){
            update(1,1,n,a,1);
        }
        else{
            update(1,1,n,a,-1);
        }
        if(mini[1]>=0){
            cout << ">" << "\n";
        }
        else if(maxi[1]<=0){
            cout << "<" << "\n";
        }
        else{
            cout << "?" << "\n"; 
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 3 ms 1184 KB Output is correct
11 Correct 19 ms 3920 KB Output is correct
12 Correct 38 ms 7332 KB Output is correct
13 Correct 29 ms 7452 KB Output is correct
14 Correct 28 ms 7424 KB Output is correct
15 Correct 27 ms 7456 KB Output is correct
16 Correct 28 ms 7424 KB Output is correct
17 Correct 27 ms 7376 KB Output is correct
18 Correct 35 ms 7348 KB Output is correct
19 Correct 28 ms 7392 KB Output is correct
20 Correct 27 ms 7336 KB Output is correct
21 Correct 29 ms 7404 KB Output is correct
22 Correct 29 ms 7436 KB Output is correct
23 Correct 27 ms 7332 KB Output is correct
24 Correct 28 ms 7356 KB Output is correct
25 Correct 28 ms 7428 KB Output is correct