Submission #336537

#TimeUsernameProblemLanguageResultExecution timeMemory
336537katearimaTrading (IZhO13_trading)C++14
0 / 100
416 ms9196 KiB
#include <bits/stdc++.h> #define ll long long #include <fstream> //#define cin infile //#define cout outfile #include <cstdlib> using namespace std; const int N=300005; const int M=300005; int m,n,l,r; ll tree[2*N+1],x,ans; void update(int i, int a, int b, int l, int r, int x){ if(r<a || l>b) return; if( a>=l && b<=r) { int k=a-l+x; if(tree[i]>k) return; tree[i]=k; return; } int mid=(a+b)/2; update(2*i+1, a, mid, l, r, x); update(2*i+2, mid+1,b, l , r, x); } void findmx(int i, int a, int b, int x){ if(x==a && x==b) { ans=tree[i]; return; } int mid=(a+b)/2; if(tree[i]!=0 && a!=b){ ll k=tree[i]; tree[2*i+1]=max(tree[2*i+1], k); tree[2*i+2]=max(tree[2*i+2], k+(mid+1-a)); tree[i]=0; } if(x<a || x>b) return; findmx(2*i+1, a, mid, x); findmx(2*i+2, mid+1, b, x); } main(){ ifstream infile; infile.open("trading.in"); ofstream outfile; outfile.open("trading.out"); cin>>n>>m; for(int i=0; i<m; i++){ cin>>l>>r>>x; l--; r--; update(0, 0, n-1, l, r, x); } for(int i=0; i<n; i++){ ans=0; findmx(0,0,n-1,i); cout<<ans<<" "; } }

Compilation message (stderr)

trading.cpp:43:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   43 | main(){
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...