Submission #129315

#TimeUsernameProblemLanguageResultExecution timeMemory
129315taozai281Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
690 ms7488 KiB
#include<bits/stdc++.h> #pragma GCC optimize ("O3") 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(){ 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++){ 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...