Submission #837542

#TimeUsernameProblemLanguageResultExecution timeMemory
837542borisAngelovFoehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
8 ms2132 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int n, q, s, t; int a[maxn]; long long delta[maxn]; void fastIO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { fastIO(); cin >> n >> q >> s >> t; for (int i = 1; i <= n + 1; ++i) { cin >> a[i]; } for (int i = 1; i <= n; ++i) { delta[i] = a[i] - a[i + 1]; } for (int i = 1; i <= q; ++i) { int l, r, val; cin >> l >> r >> val; if (l != 0) { delta[l] -= val; } if (r != n) { delta[r + 1] += val; } long long ans = 0; for (int j = 1; j <= n; ++j) { if (delta[j] < 0) { ans += delta[j] * (1LL * s); } else { ans += delta[j] * (1LL * t); } } cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...