Submission #209153

#TimeUsernameProblemLanguageResultExecution timeMemory
209153bensonlzlFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
147 ms5752 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll N, Q, S, T, X, L, R, diff[200005], cont[200005], init = 0; ll cost(int x){ if (diff[x] < 0) return -T*diff[x]; else return -S*diff[x]; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> N >> Q >> S >> T; for (int i = 0; i <= N; ++i) cin >> diff[i]; for (int i = N; i >= 1; --i) diff[i] -= diff[i-1]; for (int i = 1; i <= N; ++i) init += cost(i); for (int i = 1; i <= Q; ++i){ cin >> L >> R >> X; init -= cost(L); if (R < N) init -= cost(R+1); diff[L] += X; diff[R+1] -= X; init += cost(L); if (R < N) init += cost(R+1); cout << init << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...