Submission #717929

#TimeUsernameProblemLanguageResultExecution timeMemory
717929thimote75Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
513 ms11644 KiB
#include <bits/stdc++.h> using namespace std; #define num long long num S, T; num res = 0; vector<num> delta; num compute (num delta) { delta *= -1; if (delta < 0) return delta * S; return delta * T; } void addDelta (int index, num value) { res -= compute(delta[index]); delta[index] += value; res += compute(delta[index]); } int main () { int N, Q; cin >> N >> Q >> S >> T; delta.resize(N); int L; cin >> L; for (int i = 0; i < N; i ++) { int x; cin >> x; addDelta(i, x - L); L = x; } for (int q = 0; q < Q; q ++) { int l, r, v; cin >> l >> r >> v; addDelta(l - 1, v); if (r != N) addDelta(r, - v); cout << res << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...