답안 #524721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
524721 2022-02-09T21:44:57 Z TheKingAleks 돌 무게 재기 (IZhO11_stones) C++14
0 / 100
0 ms 332 KB
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 1e6+2;
pair<int,int> tree[MAX_N*4];
int lazy[MAX_N*4];
void update(int node, int tl, int tr, int l, int r, int val)
{
    if(lazy[node])
    {
        tree[node].first += lazy[node];
        tree[node].second += lazy[node];
        if(tl != tr)
        {
            lazy[node*2]+=lazy[node];
            lazy[node*2+1]+=lazy[node];
        }
    }
    if(tl >= l && tr <= r)
    {
        tree[node].first += val;
        tree[node].second += val;
        if(tl != tr)
        {
            lazy[node*2]+=val;
            lazy[node*2+1]+=val;
        }
        return;
    }
    if(tl > r || tr < l) return;
    int mid = (tl+tr)/2;
    update(node*2, tl, mid, l, r, val);
    update(node*2+1, mid+1, tr, l, r, val);
    tree[node].first = max(tree[node*2].first,tree[node*2+1].first);
    tree[node].second = min(tree[node*2].second,tree[node*2+1].second);
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int s;
    cin>>s;
    for(int i=0; i<s; i++)
    {
        int val,flag;
        cin>>val>>flag;
        if(flag == 1)
        {
            update(1,1,100000,1,val,1);
        }
        else
        {
            update(1,1,100000,1,val,-1);
        }
        if(tree[1].first >= 0 && tree[1].second >= 0) cout<<">"<<endl;
        else if(tree[1].first <= 0 && tree[1].second <= 0) cout<<"<"<<endl;
        else cout<<"?"<<endl;

    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -