Submission #129286

#TimeUsernameProblemLanguageResultExecution timeMemory
129286iqvocucFoehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
662 ms4152 KiB
/*** * _ ____ _____ _ * /\/\ /_\ /___ \ /\ /\ \_ \ /_\ * / \ //_\\ // / / / / \ \ / /\/ //_\\ * / /\/\ \ / _ \ / \_/ / \ \_/ / /\/ /_ / _ \ * \/ \/ \_/ \_/ \___,_\ \___/ \____/ \_/ \_/ * */ #include<bits/stdc++.h> using namespace std; int n,q,s,t; int a[2000005]; int diff[2000005]; int tong; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>q>>s>>t; for(int i=0;i<=n;i++){ cin>>a[i]; } for(int i=1;i<=n;i++){ diff[i]=a[i-1]-a[i]; if(diff[i]<0){ tong+=diff[i]*s; } else { tong+=diff[i]*t; } } while(q--){ int l,r,x; cin>>l>>r>>x; if(diff[l]<0) tong-=diff[l]*s; else tong-=diff[l]*t; diff[l]-=x; if(diff[l]<0) tong+=diff[l]*s; else tong+=diff[l]*t; if(r<n){ if(diff[r+1]<0) tong-=diff[r+1]*s; else tong-=diff[r+1]*t; diff[r+1]+=x; if(diff[r+1]<0) tong+=diff[r+1]*s; else tong+=diff[r+1]*t; } cout<<tong<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...