제출 #197054

#제출 시각아이디문제언어결과실행 시간메모리
197054JuneyFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
146 ms12892 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2e5 + 5; int N, Q; ll S, T, A[MAXN], B[MAXN], ans; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> N >> Q >> S >> T; for(int i=0; i<=N; i++) cin >> A[i]; for(int i=1; i<=N; i++) { B[i] = A[i] - A[i-1]; if(B[i] >= 0) ans -= B[i] * S; else ans -= B[i] * T; } while(Q--) { int l, r, x; cin >> l >> r >> x; if(B[l] >= 0) ans += B[l] * S; else ans += B[l] * T; if(r < N) { if(B[r+1] >= 0) ans += B[r+1] * S; else ans += B[r+1] * T; } B[l] += x; if(r < N) B[r+1] -= x; if(B[l] >= 0) ans -= B[l] * S; else ans -= B[l] * T; if(r < N) { if(B[r+1] >= 0) ans -= B[r+1] * S; else ans -= B[r+1] * T; } cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...