Submission #883645

#TimeUsernameProblemLanguageResultExecution timeMemory
883645maxFedorchukFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
94 ms11560 KiB
#include <bits/stdc++.h> using namespace std; const long long MX=2e5+10; long long a[MX]; long long s,t; long long cnt(long long zn) { if(zn>0) { return ((-zn)*s); } else { return ((-zn)*t); } } int main() { cin.tie(0); ios_base::sync_with_stdio(0); long long n,q; cin>>n>>q>>s>>t; for(long long i=0;i<=n;i++) { cin>>a[i]; } for(long long i=n;i>=1;i--) { a[i]-=a[i-1]; } long long tmp=0; for(long long i=1;i<=n;i++) { tmp+=cnt(a[i]); //cout<<a[i]<<" "<<cnt(a[i])<<"\n"; } //cout<<tmp<<"\n"; long long l,r,x; while(q--) { cin>>l>>r>>x; tmp-=cnt(a[l]); a[l]+=x; tmp+=cnt(a[l]); if(r!=n) { tmp-=cnt(a[r+1]); a[r+1]-=x; tmp+=cnt(a[r+1]); } cout<<tmp<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...