제출 #33257

#제출 시각아이디문제언어결과실행 시간메모리
33257minkankFoehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
16 ms3736 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, m, s, t; long long ans = 0, a[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m >> t >> s; for(int i = 0; i <= n; ++i) cin >> a[i]; for(int i = n; i >= 1; --i) { a[i] -= a[i - 1]; if(a[i] > 0) ans -= a[i] * t; else ans += -a[i] * s; } for(int i = 0; i < m; ++i) { int l, r, x; cin >> l >> r >> x; if(a[l] > 0) ans += a[l] * t; else ans -= -a[l] * s; a[l] += x; if(a[l] > 0) ans -= a[l] * t; else ans += -a[l] * s; if(r != n) { if(a[r + 1] > 0) ans += a[r + 1] * t; else ans -= -a[r + 1] * s; a[r + 1] -= x; if(a[r + 1] > 0) ans -= a[r + 1] * t; else ans += -a[r + 1] * s; } cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...