Submission #499291

# Submission time Handle Problem Language Result Execution time Memory
499291 2021-12-27T19:47:50 Z reni Weighting stones (IZhO11_stones) C++14
100 / 100
63 ms 7540 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(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(le>r || ri<l)return;
    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:41:18: warning: unused variable 'j' [-Wunused-variable]
   41 |    long long n,i,j,r,s;
      |                  ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 5 ms 1148 KB Output is correct
11 Correct 31 ms 3828 KB Output is correct
12 Correct 53 ms 7344 KB Output is correct
13 Correct 45 ms 7336 KB Output is correct
14 Correct 43 ms 7368 KB Output is correct
15 Correct 43 ms 7344 KB Output is correct
16 Correct 44 ms 7332 KB Output is correct
17 Correct 59 ms 7432 KB Output is correct
18 Correct 44 ms 7344 KB Output is correct
19 Correct 44 ms 7440 KB Output is correct
20 Correct 43 ms 7380 KB Output is correct
21 Correct 63 ms 7412 KB Output is correct
22 Correct 45 ms 7540 KB Output is correct
23 Correct 42 ms 7448 KB Output is correct
24 Correct 44 ms 7384 KB Output is correct
25 Correct 57 ms 7408 KB Output is correct