# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
955530 | Kakarot | Foehn Phenomena (JOI17_foehn_phenomena) | C++98 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>#define int int64_tusing namespace std;void setIO() { cin.tie(0)->sync_with_stdio(0);}void solve() { int n, q, s, t; cin >> n >> q >> s >> t; vector<int> a(n+2), temp(n+1); for(int i = 0; i <= n; i++) cin >> a[i]; while(q--) { int l, r, x; cin >> l >> r >> x; a[l] += x, a[r+1] -= x; } for(int i = 1; i <= n; i++) a[i] += a[i-1]; for(int i = 1; i <= n; i++) temp[i] = temp[i-1] + (a[i] <= a[i-1] ? (a[i-1]-a[i])*t : (a[i]-a[i-1])*s); cout << temp[n];}int32_t main() { setIO(); solve(); return 0;}