# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
499291 | reni | Weighting stones (IZhO11_stones) | C++14 | 63 ms | 7540 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |