Submission #499289

#TimeUsernameProblemLanguageResultExecution timeMemory
499289reniWeighting stones (IZhO11_stones)C++14
0 / 100
1 ms332 KiB
#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 (stderr)

stones.cpp: In function 'int main()':
stones.cpp:43:18: warning: unused variable 'j' [-Wunused-variable]
   43 |    long long n,i,j,r,s;
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...