제출 #922100

#제출 시각아이디문제언어결과실행 시간메모리
922100406Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
93 ms11648 KiB
#include <bits/stdc++.h> #define int int64_t #define FOR(i, a, b) for (int i = (a); i < (b); ++i) using namespace std; using ar = array<int, 2>; const int64_t INF = 1ll << 60; const int N = 2e5 + 5; int n, q, a[N], S, T, sum; void add(int x, const int d = 1) { sum -= d * (x > 0 ? S : T) * x; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> q >> S >> T; FOR(i, 0, n + 1) cin >> a[i]; FOR(i, 0, n) { a[i] = a[i + 1] - a[i]; add(a[i]); } while (q--) { int l, r, x; cin >> l >> r >> x; --l; if (r < n) { add(a[r], -1); a[r] -= x; add(a[r]); } if (l >= 0) { add(a[l], -1); a[l] += x; add(a[l]); } cout << sum << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...