Submission #1270208

#TimeUsernameProblemLanguageResultExecution timeMemory
1270208sqwiijqkFoehn Phenomena (JOI17_foehn_phenomena)C++20
100 / 100
82 ms5704 KiB
#include <bits/stdc++.h> #include <experimental/random> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; void solve1(); using ll = long long; using ull = unsigned long long; using ld = double; #define int long long const int INF = 1e17; const int MOD = 998244353; signed main() { #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int qwerty = 1; // cin >> qwerty; while (qwerty--) { solve1(); } } void solve1() { int n, q, s, t; cin >> n >> q >> s >> t; vector<int> a(n); { int x; cin >> x; } int last = 0; for (int i = 0; i < n; i++) { cin >> a[i]; a[i] -= last; last += a[i]; } int ans = 0; for (int i = 0; i < n; i++) { if (a[i] < 0) { ans -= (a[i]) * t; } else { ans -= (a[i]) * s; } } while (q--) { int l, r, x; cin >> l >> r >> x; l--; r--; if (a[l] < 0) { ans += a[l] * t; } else { ans += a[l] * s; } a[l] += x; if (a[l] < 0) { ans -= a[l] * t; } else { ans -= a[l] * s; } if (r + 1 < n) { if (a[r + 1] < 0) { ans += (a[r + 1]) * t; } else { ans += (a[r + 1]) * s; } a[r + 1] -= x; if (a[r + 1] < 0) { ans -= (a[r + 1]) * t; } else { ans -= (a[r + 1]) * s; } } cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...