Submission #764544

# Submission time Handle Problem Language Result Execution time Memory
764544 2023-06-23T14:49:20 Z Trunkty Weighting stones (IZhO11_stones) C++14
100 / 100
30 ms 3744 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 340 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 340 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 724 KB Output is correct
11 Correct 17 ms 2024 KB Output is correct
12 Correct 27 ms 3672 KB Output is correct
13 Correct 28 ms 3624 KB Output is correct
14 Correct 30 ms 3660 KB Output is correct
15 Correct 29 ms 3684 KB Output is correct
16 Correct 26 ms 3616 KB Output is correct
17 Correct 25 ms 3704 KB Output is correct
18 Correct 28 ms 3628 KB Output is correct
19 Correct 28 ms 3744 KB Output is correct
20 Correct 25 ms 3660 KB Output is correct
21 Correct 26 ms 3668 KB Output is correct
22 Correct 26 ms 3640 KB Output is correct
23 Correct 25 ms 3676 KB Output is correct
24 Correct 26 ms 3660 KB Output is correct
25 Correct 26 ms 3636 KB Output is correct