Submission #523963

#TimeUsernameProblemLanguageResultExecution timeMemory
523963MonarchuwuFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
111 ms13148 KiB
#include<iostream> #include<algorithm> using namespace std; typedef long long ll; const int N = 2e5 + 8; int n, q, s, t; ll a[N], d[N]; ll get(ll x) { if (x > 0) return -x * s; return -x * t; } int main() { cin.tie(NULL)->sync_with_stdio(false); cin >> n >> q >> s >> t; for (int i = 0; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= n; ++i) d[i] = a[i] - a[i - 1]; ll sum(0); for (int i = 1; i <= n; ++i) sum += get(d[i]); int l, r, x; while (q--) { cin >> l >> r >> x; // l and r+1 sum -= get(d[l]); d[l] += x; sum += get(d[l]); if (r != n) { sum -= get(d[r + 1]); d[r + 1] -= x; sum += get(d[r + 1]); } cout << sum << '\n'; } } /** /\_/\ * (= ._.) * / >0 \>1 **/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...