제출 #684469

#제출 시각아이디문제언어결과실행 시간메모리
684469kussssoFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
103 ms12384 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5 + 5; int n, q; ll s, t; int a[N]; ll d[N]; ll decr, incr; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> q >> s >> t; s = -s; for (int i = 0; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { d[i] = a[i] - a[i - 1]; if (d[i] > 0) decr += d[i]; else incr += abs(d[i]); } while (q--) { int l, r, x; cin >> l >> r >> x; if (d[l] > 0) decr -= d[l]; else incr -= abs(d[l]); d[l] += x; if (d[l] > 0) decr += d[l]; else incr += abs(d[l]); if (r + 1 <= n) { if (d[r + 1] > 0) decr -= d[r + 1]; else incr -= abs(d[r + 1]); d[r + 1] -= x; if (d[r + 1] > 0) decr += d[r + 1]; else incr += abs(d[r + 1]); } cout << decr * s + incr * t << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...