제출 #545644

#제출 시각아이디문제언어결과실행 시간메모리
545644pokmui9909Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
138 ms11468 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll N, Q, S, T; ll A[200005]; ll f(ll k){ return (A[k] > 0 ? -S * A[k] : -T * A[k]); } int main(){ cin.tie(0) -> sync_with_stdio(false); cin >> N >> Q >> S >> T; ll r = 0; for(int i = 0; i <= N; i++){ cin >> A[i]; } for(int i = N; i >= 1; i--){ A[i] -= A[i - 1]; r += f(i); } while(Q--){ ll L, R, X; cin >> L >> R >> X; r -= f(L); A[L] += X; r += f(L); if(R + 1 <= N) { r -= f(R + 1); A[R + 1] -= X; r += f(R + 1); } cout << r << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...