Submission #1264402

#TimeUsernameProblemLanguageResultExecution timeMemory
1264402happyboyFoehn Phenomena (JOI17_foehn_phenomena)C++20
100 / 100
320 ms7312 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll n,q,s,t,l,r,x,tmp,a[200001],d[200001]; int main(){ cin>>n>>q>>s>>t; for (int i=0;i<=n;i++){ cin>>a[i]; if (i>0){ d[i]=a[i]-a[i-1]; if (d[i]>0) tmp-=d[i]*s; else tmp-=d[i]*t; } } while (q--){ cin>>l>>r>>x; if (d[l]<0){ if (d[l]+x<0) tmp-=x*t; else tmp+=d[l]*t-(d[l]+x)*s; } else{ if (d[l]+x>0) tmp-=x*s; else tmp+=d[l]*s-(d[l]+x)*t; } if (r+1>n) goto a; if (d[r+1]<0){ if (d[r+1]-x<0) tmp+=x*t; else tmp+=d[r+1]*t-(d[r+1]-x)*s; } else{ if (d[r+1]-x>0) tmp+=x*s; else tmp+=d[r+1]*s-(d[r+1]-x)*t; } d[r+1]-=x; a:; d[l]+=x; cout<<tmp<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...