Submission #82602

#TimeUsernameProblemLanguageResultExecution timeMemory
82602Bodo171Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
774 ms168324 KiB
#include <iostream> #include <fstream> using namespace std; const int nmax=200005; long long a[nmax]; long long s,t,ans,k; int n,q,i,l,r; long long calc(long long x) { if(x>0) return -x*s; return -x*t; } int main() { //freopen("data.in","r",stdin); cin>>n>>q>>s>>t; for(i=0;i<=n;i++) cin>>a[i]; for(i=n;i>=1;i--) { a[i]=a[i]-a[i-1]; ans+=calc(a[i]); } for(int cnt=1;cnt<=q;cnt++) { cin>>l>>r>>k; ans-=calc(a[l]); if(r<n)ans-=calc(a[r+1]); a[l]+=k; a[r+1]-=k; ans+=calc(a[l]); if(r<n)ans+=calc(a[r+1]); cout<<ans<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...