Submission #1123950

#TimeUsernameProblemLanguageResultExecution timeMemory
1123950njoopFoehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
429 ms3892 KiB
#include <bits/stdc++.h> using namespace std; int n, q, s, t, ans, arr[200010], dif[200010], l, r, x; int find(int num) { if(num > 0) return num*t; else return num*s; } int main() { cin >> n >> q >> s >> t; n++; for(int i=1; i<=n; i++) { cin >> arr[i]; } for(int i=2; i<=n; i++) { dif[i-1] = arr[i-1]-arr[i]; ans += find(dif[i-1]); } while(q--) { cin >> l >> r >> x; l++; r++; if(l != 1) { ans -= find(dif[l-1]); dif[l-1] -= x; ans += find(dif[l-1]); } if(r < n) { ans -= find(dif[r]); dif[r] += x; ans += find(dif[r]); } cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...