제출 #321638

#제출 시각아이디문제언어결과실행 시간메모리
321638casperwangFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
132 ms13164 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int MAXN = 200000; int n, q, s, t; int l, r, x; int a[MAXN+1]; int d[MAXN+1]; int ans; signed main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> n >> q >> s >> t; for (int i = 0; i <= n; i++) { cin >> a[i]; if (i) d[i] = a[i] - a[i-1]; } for (int i = 1; i <= n; i++) ans += -(d[i] > 0 ? s : t) * d[i]; for (int i = 1; i <= q; i++) { cin >> l >> r >> x; ans -= -(d[l] > 0 ? s : t) * d[l]; d[l] += x; ans += -(d[l] > 0 ? s : t) * d[l]; if (r < n) { ans -= -(d[r+1] > 0 ? s : t) * d[r+1]; d[r+1] -= x; ans += -(d[r+1] > 0 ? s : t) * d[r+1]; } cout << ans << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...