Submission #173149

#TimeUsernameProblemLanguageResultExecution timeMemory
173149juggernautTrading (IZhO13_trading)C++14
100 / 100
263 ms10708 KiB
//Just try and the idea will come! #include<bits/stdc++.h> using namespace std; int flag[1200001],n,m,x,y,z; void update(int v,int l,int r,int ql,int qr,int val){ if(r<ql||qr<l)return; if(ql<=l&&r<=qr){ flag[v]=max(flag[v],val); return; } int mid=(l+r)>>1; update((v<<1),l,mid,ql,qr,val); update((v<<1)+1,mid+1,r,ql,qr,val+mid-l+1); } void push(int v,int l,int r){ int mid=(l+r)>>1; if(l!=r){ if(flag[v]){ flag[(v<<1)]=max(flag[(v<<1)],flag[v]); flag[(v<<1)+1]=max(flag[(v<<1)+1],flag[v]+mid-l+1); } }else{ printf("%d ",flag[v]); return; } push((v<<1),l,mid); push((v<<1)+1,mid+1,r); } int main(){ scanf("%d%d",&n,&m); while(m--){ scanf("%d%d%d",&x,&y,&z); update(1,1,n,x,y,z-x+1); } push(1,1,n); }

Compilation message (stderr)

trading.cpp: In function 'int main()':
trading.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
trading.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&x,&y,&z);
         ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...