Submission #897356

#TimeUsernameProblemLanguageResultExecution timeMemory
897356boxFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
87 ms12372 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0); int n, q, s, t; cin >> n >> q >> s >> t, n++; vector<int> a(n); for (int& x : a) cin >> x; vector<long long> d(n - 1); long long c = 0; auto upd = [&](int i, int x) { c -= d[i] * (d[i] >= 0 ? t : s); d[i] += x; c += d[i] * (d[i] >= 0 ? t : s); }; for (int i = 0; i < n - 1; i++) upd(i, a[i] - a[i + 1]); while (q--) { int l, r, x; cin >> l >> r >> x; upd(l - 1, -x); if (r < n - 1) upd(r, +x); cout << c << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...