Submission #170861

#TimeUsernameProblemLanguageResultExecution timeMemory
170861juggernautWeighting stones (IZhO11_stones)C++14
100 / 100
71 ms7672 KiB
//Just try and the idea will come! #include<bits/stdc++.h> #define int long long int using namespace std; int mx[400001],mn[400001],add[400001],n,x,y,i; void push(int v,int l,int r){ if(l!=r){ add[v*2]+=add[v]; add[v*2+1]+=add[v]; } mx[v]+=add[v]; mn[v]+=add[v]; add[v]=0; } void update(int v,int l,int r,int ql,int qr,int val){ push(v,l,r); if(r<ql||qr<l)return; if(ql<=l&&r<=qr){ add[v]+=val; push(v,l,r); return; } int mid=(l+r)>>1; update(v*2,l,mid,ql,qr,val); update(v*2+1,mid+1,r,ql,qr,val); mx[v]=max(mx[v*2],mx[v*2+1]); mn[v]=min(mn[v*2],mn[v*2+1]); } main(){ scanf("%lld",&n); for(i=0;i<n;i++){ scanf("%lld%lld",&x,&y); update(1,1,n,1,x,3-y*2); if(mx[1]>=0&&mn[1]>=0)puts(">"); else if(mx[1]<=0&&mn[1]<=0)puts("<"); else puts("?"); } }

Compilation message (stderr)

stones.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
stones.cpp: In function 'int main()':
stones.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
stones.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld",&x,&y);
         ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...