Submission #129312

#TimeUsernameProblemLanguageResultExecution timeMemory
129312taozai281Foehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
1004 ms5020 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int n,q,s,t; int a[200010]; int b[200010]; int l,r,x; long long res=0; int cal(int x){ if(x<0){ return x*s; } else return x*t; } signed main(){ cin>>n>>q>>s>>t; for(int i=0;i<=n;i++) { cin>>a[i]; } for(int i=1;i<=n;i++){ b[i]=a[i-1]-a[i]; res+=cal(b[i]); } while(q--){ cin>>l>>r>>x; res -= cal(b[l]); b[l] -= x; res += cal(b[l]); if (r < n) { res -= cal(b[r + 1]); b[r + 1] += x; res += cal(b[r + 1]); } cout<<res<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...