답안 #711683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
711683 2023-03-17T11:08:42 Z Darren0724 돌 무게 재기 (IZhO11_stones) C++17
100 / 100
70 ms 16916 KB
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define int long long
const int mod=1e9+7;
const int INF=2e18;
const int N=100005;
struct seg{
    int l,r,m;
    seg *lc,*rc;
    int val=0,mn=0,mx=0,lz=0;
    int rmax(){
        return mx+lz;
    }
    int rmin(){
        return mn+lz;
    }
    void pull(){
        mn=min(lc->rmin(),rc->rmin());
        mx=max(lc->rmax(),rc->rmax());
    }
    void push(){
        lc->lz+=lz;
        rc->lz+=lz;
        lz=0;
    }
    seg(int l1,int r1){
        l=l1,r=r1;
        m=(l+r)>>1;
        if(r-l==1){
            return;
        }
        lc=new seg(l,m);
        rc=new seg(m,r);
    }
    void add(int a,int b,int x){
        if(a<=l&&b>=r){
            //cout<<l<<' '<<r<<' '<<x<<endl;
            lz+=x;
            return;
        }
        push();
        if(a<m){
            lc->add(a,b,x);
        }
        if(b>m){
            rc->add(a,b,x);
        }
        pull();
    }
};
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    seg* tr=new seg(0,N);
    for(int i=0;i<n;i++){
        int a,b;cin>>a>>b;
        tr->add(1,a+1,(b==1?1:-1));
        if(tr->mn==0){
            cout<<">\n";
        }
        else if(tr->mx==0){
            cout<<"<\n";
        }
        else{
            cout<<"?\n";
        }
    }


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 15956 KB Output is correct
2 Correct 10 ms 15956 KB Output is correct
3 Correct 11 ms 15936 KB Output is correct
4 Correct 12 ms 15928 KB Output is correct
5 Correct 11 ms 15924 KB Output is correct
6 Correct 12 ms 15956 KB Output is correct
7 Correct 12 ms 15980 KB Output is correct
8 Correct 11 ms 15956 KB Output is correct
9 Correct 11 ms 15956 KB Output is correct
10 Correct 16 ms 16036 KB Output is correct
11 Correct 46 ms 16456 KB Output is correct
12 Correct 70 ms 16724 KB Output is correct
13 Correct 51 ms 16896 KB Output is correct
14 Correct 51 ms 16876 KB Output is correct
15 Correct 53 ms 16876 KB Output is correct
16 Correct 54 ms 16888 KB Output is correct
17 Correct 58 ms 16836 KB Output is correct
18 Correct 56 ms 16884 KB Output is correct
19 Correct 55 ms 16916 KB Output is correct
20 Correct 55 ms 16892 KB Output is correct
21 Correct 50 ms 16844 KB Output is correct
22 Correct 55 ms 16820 KB Output is correct
23 Correct 51 ms 16908 KB Output is correct
24 Correct 51 ms 16860 KB Output is correct
25 Correct 53 ms 16864 KB Output is correct