Submission #995267

#TimeUsernameProblemLanguageResultExecution timeMemory
995267gmroh06Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
85 ms13232 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<ll, ll>; inline void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } const ll INF = 1e16; ll n, q, s, t, sum; ll arr[200005], diff[200005]; ll cal(ll x) { if (x < 0) { return -t * x; } else { return -s * x; } } int main() { fastio(); cin >> n >> q >> s >> t; for (ll i = 0; i <= n; i++) { cin >> arr[i]; } for (ll i = 1; i <= n; i++) { diff[i] = arr[i] - arr[i - 1]; sum += cal(diff[i]); } ll l, r, x; while (q--) { cin >> l >> r >> x; sum -= cal(diff[l]) + (r != n) * cal(diff[r + 1]); diff[l] += x; diff[r + 1] -= (r != n) * x; sum += cal(diff[l]) + (r != n) * cal(diff[r + 1]); cout << sum << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...