Submission #807090

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