Submission #751699

#TimeUsernameProblemLanguageResultExecution timeMemory
751699tch1cherinFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
105 ms13064 KiB
#include <bits/stdc++.h> using namespace std; void solve() { int N, Q, S, T; cin >> N >> Q >> S >> T; vector<long long> A(N + 1); for (auto &v : A) { cin >> v; } long long sum_neg = 0, sum_pos = 0; auto Add = [&](long long val, int sign) { if (val < 0) { sum_neg += sign * val; } else { sum_pos += sign * val; } }; vector<long long> D(N); for (int i = 0; i < N; i++) { D[i] = A[i + 1] - A[i]; Add(D[i], 1); } while (Q--) { int L, R, X; cin >> L >> R >> X; if (R < N) { Add(D[R], -1); D[R] -= X; Add(D[R], 1); } Add(D[L - 1], -1); D[L - 1] += X; Add(D[L - 1], 1); cout << -(sum_pos * S + sum_neg * T) << "\n"; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...