Submission #1150840

#TimeUsernameProblemLanguageResultExecution timeMemory
1150840pinbuFoehn Phenomena (JOI17_foehn_phenomena)C++20
30 / 100
74 ms5192 KiB
#include <bits/stdc++.h> using namespace std; const int N = 200005; const long long oo = 1e18; int n, q, s, t, a[N], d[N]; void solve(void) { cin >> n >> q >> s >> t; long long ans = 0; cin >> a[0]; for (int i = 1; i <= n; i++) { cin >> a[i]; d[i] = a[i - 1] - a[i]; ans += 1LL * d[i] * (a[i - 1] < a[i] ? s : t); } auto update = [&] (int i, int x) { ans -= 1LL * d[i] * (d[i] < 0 ? s : t); d[i] += x; ans += 1LL * d[i] * (d[i] < 0 ? s : t); }; while (q--) { int l, r, x; cin >> l >> r >> x; update(l, -x); if (r < n) update(r + 1, +x); cout << ans << '\n'; } } signed main(void) { ios::sync_with_stdio(false); cin.tie(nullptr); int T = 1;// cin >> T; while (T--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...