제출 #765460

#제출 시각아이디문제언어결과실행 시간메모리
765460NK_Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
101 ms7268 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> using namespace std; #define nl '\n' using ll = long long; template<class T> using V = vector<T>; int main() { cin.tie(0)->sync_with_stdio(0); int N, M; ll S, T; cin >> N >> M >> S >> T; V<ll> A(N+1); for(auto& x : A) cin >> x; ll ans = 0; V<ll> D(N); for(int i = 0; i < N; i++) D[i] = A[i] - A[i + 1]; auto upd = [&](int x) { if (D[x] < 0) return S * D[x]; else return T * D[x]; }; for(int i = 0; i < N; i++) ans += upd(i); for(int q = 0; q < M; q++) { int l, r; ll x; cin >> l >> r >> x; { ans -= upd(l - 1); D[l - 1] -= x; ans += upd(l - 1); } if (r < N) { ans -= upd(r); D[r] += x; ans += upd(r); } cout << ans << nl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...