Submission #855722

#TimeUsernameProblemLanguageResultExecution timeMemory
855722annabeth9680Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
80 ms13136 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N,Q,S,T; cin >> N >> Q >> S >> T; vector<int> arr(N+1),diff(N+1); cin >> arr[0]; for(int i = 1;i<=N;++i){ cin >> arr[i]; diff[i] = arr[i]-arr[i-1]; } int ans = 0; for(int i = 1;i<=N;++i){ if(diff[i] > 0) ans -= diff[i]*S; else ans -= diff[i]*T; } //cout << ans << "\n"; while(Q--){ int l,r,x; cin >> l >> r >> x; if(diff[l] > 0) ans += diff[l]*S; else ans += diff[l]*T; diff[l] += x; if(diff[l] > 0) ans -= diff[l]*S; else ans -= diff[l]*T; //cout << ans << "\n"; if(r < N){ if(diff[r+1] > 0) ans += diff[r+1]*S; else ans += diff[r+1]*T; diff[r+1] -= x; if(diff[r+1] > 0) ans -= diff[r+1]*S; else ans -= diff[r+1]*T; } cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...