Submission #1031695

#TimeUsernameProblemLanguageResultExecution timeMemory
1031695juicyFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
73 ms13136 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<long long> 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...