Submission #68223

#TimeUsernameProblemLanguageResultExecution timeMemory
68223NurlykhanFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
842 ms7572 KiB
#include <bits/stdc++.h> #define pb push_back #define all(v) v.begin(), v.end() #define sz(v) int(v.size()) #define pii pair<int, int> #define mp make_pair #define f first #define ll long long #define ld long double #define s second #define vec vector<int> using namespace std; const int N = (int) 2e5 + 10; const int M = (int) 2018 * 2018; const int K = (int) 15; const int INF = (int) 1e9 + 7; const int mod = (int) 998244353; const ld EPS = (ld) 1e-9; const ll LINF = (ll) 1e18; int n, q; ll s, t; ll a[N], b[N]; ll sum; void upd(int id, int val) { if (b[id] > 0) { sum += b[id] * s; } else { sum += b[id] * t; } b[id] += val; if (b[id] > 0) { sum -= b[id] * s; } else { sum -= b[id] * t; } } int main() { #ifdef sony freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif srand(time(0)); cin >> n >> q >> s >> t; for (int i = 0; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { upd(i, a[i] - a[i - 1]); } while (q--) { int l, r, x; cin >> l >> r >> x; upd(l, x); if (r < n) upd(r + 1, -x); cout << sum << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...