답안 #499289

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499289 2021-12-27T19:33:14 Z reni 돌 무게 재기 (IZhO11_stones) C++14
0 / 100
1 ms 332 KB
#include<iostream>
#include<algorithm>
#define endl '\n'
using namespace std;
long long mini[10000000], maxi[10000000], lazy[10000000];

void update(long long le,long long ri,long long l,long long r,long long ind,long long val)
{
    if(le>r || ri<l)return;
    if(l<=le && ri<=r)
    {
        lazy[ind]+=val;
    }
    mini[ind]+=lazy[ind];
    maxi[ind]+=lazy[ind];
    if(lazy[ind]!=0)
    {
        if(le!=ri)
        {

         lazy[2*ind]+=lazy[ind];
         lazy[2*ind+1]+=lazy[ind];

        }
        lazy[ind]=0;
    }
    if(l<=le && ri<=r)return;

    long long mid=(le+ri)/2;

    update(le,mid,l,r,2*ind,val);
    update(mid+1,ri,l,r,2*ind+1,val);

    mini[ind]=min(mini[2*ind], mini[2*ind+1]);
    maxi[ind]=max(maxi[2*ind], maxi[2*ind+1]);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

   long long n,i,j,r,s;

   cin>>n;

   for(i=1;i<=n;i++)
   {
       cin>>r>>s;

       if(s==1)
       {
           update(1,n,1,r,1,1);
       }
       else update(1,n,1,r,1,-1);

       if(mini[1]>=0)cout<<">"<<endl;
       else if(maxi[1]<=0)cout<<"<"<<endl;
       else cout<<"?"<<endl;
   }

}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:43:18: warning: unused variable 'j' [-Wunused-variable]
   43 |    long long n,i,j,r,s;
      |                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Incorrect 0 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -