제출 #211786

#제출 시각아이디문제언어결과실행 시간메모리
211786skytectFoehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
142 ms5624 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll n, q, s, t, d[200000], up = 0, down = 0; void update(ll p, ll x) { if (p < 1 or p > n) return; if (d[p] > 0) up -= d[p]; else down += d[p]; d[p] += x; if (d[p] > 0) up += d[p]; else down -= d[p]; } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> q >> s >> t; ll last = 0; for (ll i = 0; i <= n; ++i) { cin >> d[i]; d[i] -= last; if (d[i] > 0) up += d[i]; else down -= d[i]; last += d[i]; } for (ll i = 0; i < q; ++i) { ll l, r, x; cin >> l >> r >> x; update(l, x); update(r + 1, -x); cout << t * down - s * up << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...