Submission #1159635

#TimeUsernameProblemLanguageResultExecution timeMemory
1159635HakunaFoehn Phenomena (JOI17_foehn_phenomena)C++20
30 / 100
1095 ms2000 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, Q, S, T; cin >> n >> Q >> S >> T; long long a[n + 1]; for (int i = 0; i <= n; i++) { cin >> a[i]; } while (Q--) { int l, r, x; cin >> l >> r >> x; long long res = 0; for (int i = l; i <= r; i++) a[i] += x; for (int i = 0; i < n; i++) { if (a[i] < a[i + 1]) { res -= S * (a[i + 1] - a[i]); } else res += T * (a[i] - a[i + 1]); } cout << res << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...