제출 #206234

#제출 시각아이디문제언어결과실행 시간메모리
206234opukittpceno_hhrFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
146 ms12024 KiB
#include <iostream> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <string> #include <cmath> #include <cstdio> #include <iomanip> #include <fstream> #include <cassert> #include <cstring> #include <unordered_set> #include <unordered_map> #include <numeric> #include <ctime> #include <bitset> #include <complex> #include <random> using namespace std; #define int long long signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, q, s, t; cin >> n >> q >> s >> t; n++; vector<int> a(n); for (auto &x : a) { cin >> x; } vector<int> dl(n - 1); for (int i = 0; i + 1 < n; i++) { dl[i] = a[i + 1] - a[i]; } auto sl = [&](int i) { if (i < 0) return (int)0; if (i + 1 == n) return (int)0; if (dl[i] >= 0) return dl[i] * s; else return dl[i] * t; }; int ans = 0; for (int i = 0; i + 1 < n; i++) { ans += sl(i); } while (q--) { int l, r, x; cin >> l >> r >> x; ans -= sl(l - 1); ans -= sl(r); dl[l - 1] += x; if (r + 1 < n) dl[r] -= x; ans += sl(l - 1); ans += sl(r); cout << -ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...