제출 #1031694

#제출 시각아이디문제언어결과실행 시간메모리
1031694juicyFoehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
68 ms10580 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q, S, T; cin >> N >> Q >> S >> T; vector<int> A(N + 1), dif(N); for (int i = 0; i <= N; ++i) { cin >> A[i]; } long long res = 0; for (int i = 0; i < N; ++i) { dif[i] = A[i] - A[i + 1]; res += (long long) abs(dif[i]) * (dif[i] >= 0 ? T : -S); } auto upd = [&](int i, int x) { res -= (long long) abs(dif[i]) * (dif[i] >= 0 ? T : -S); dif[i] += x; res += (long long) abs(dif[i]) * (dif[i] >= 0 ? T : -S); }; while (Q--) { int l, r, x; cin >> l >> r >> x; upd(l - 1, -x); if (r < N) { upd(r, x); } cout << res << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...