Submission #673549

#TimeUsernameProblemLanguageResultExecution timeMemory
673549ReLiceTrading (IZhO13_trading)C++14
100 / 100
458 ms36092 KiB
#include<bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long #define pb push_back #define fr first #define sc second void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll N = 4e5 + 10 ; const ll mod=1e9+7; vector <ll> ans(N),t(4*N),add(4*N); void push(ll v,ll tl,ll tr){ if(add[v]==0) return; if(tl==tr){ t[v]=max(t[v],add[v]); } else{ ll tm=(tl+tr)/2; add[v*2]=max(add[v*2],add[v]); add[v*2+1]=max(add[v*2+1],add[v]+tm-tl+1); } add[v]=0; } void up(ll v,ll tl,ll tr,ll l,ll r,ll val){ push(v,tl,tr); if(tr<l || tl>r) return; if(l<=tl && tr<=r){ add[v]=val+tl-l; push(v,tl,tr); return; } ll tm=(tl+tr)/2; up(v*2,tl,tm,l,r,val); up(v*2+1,tm+1,tr,l,r,val); } void go(ll v,ll tl,ll tr){ push(v,tl,tr); if(tl==tr) { ans[tl]=max(ans[tl],t[v]); return; } ll tm=(tl+tr)/2; go(v*2,tl,tm); go(v*2+1,tm+1,tr); } void solve(){ ll n,i,x,y,l,r; ll m,k,sum2=0,c=0,j,b; cin>>n>>m; vector <pair<ll,pair<ll,ll>>> v; for(i=0;i<m;i++){ cin>>l>>r>>x; up(1,1,n,l,r,x); } sort(v.begin(),v.end()); go(1,1,n); for(i=1;i<=n;i++) cout<<ans[i]<<' '; cout<<endl; } main(){ //fre(""); //start(); ll t=1; //cin>>t; while(t--)solve(); }

Compilation message (stderr)

trading.cpp: In function 'void solve()':
trading.cpp:51:14: warning: unused variable 'y' [-Wunused-variable]
   51 |     ll n,i,x,y,l,r;
      |              ^
trading.cpp:52:10: warning: unused variable 'k' [-Wunused-variable]
   52 |     ll m,k,sum2=0,c=0,j,b;
      |          ^
trading.cpp:52:12: warning: unused variable 'sum2' [-Wunused-variable]
   52 |     ll m,k,sum2=0,c=0,j,b;
      |            ^~~~
trading.cpp:52:19: warning: unused variable 'c' [-Wunused-variable]
   52 |     ll m,k,sum2=0,c=0,j,b;
      |                   ^
trading.cpp:52:23: warning: unused variable 'j' [-Wunused-variable]
   52 |     ll m,k,sum2=0,c=0,j,b;
      |                       ^
trading.cpp:52:25: warning: unused variable 'b' [-Wunused-variable]
   52 |     ll m,k,sum2=0,c=0,j,b;
      |                         ^
trading.cpp: At global scope:
trading.cpp:64:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   64 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...