제출 #1116095

#제출 시각아이디문제언어결과실행 시간메모리
1116095staszic_ojuzFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
83 ms12360 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, q, s, t; cin >> n >> q >> s >> t; vector<int> A(n + 1); for (int &a : A) { cin >> a; } vector<int64_t> deltas(n); int64_t non_neg_deltas = 0, neg_deltas = 0; auto upd_deltas = [&](int i, int64_t by_val) { if (i >= n) { return; } (deltas[i] < 0 ? neg_deltas : non_neg_deltas) -= deltas[i]; deltas[i] += by_val; (deltas[i] < 0 ? neg_deltas : non_neg_deltas) += deltas[i]; }; for (int i = 0; i < n; ++i) { upd_deltas(i, A[i] - A[i + 1]); } for (int i = 0; i < q; ++i) { int l, r, x; cin >> l >> r >> x; upd_deltas(l - 1, -x); upd_deltas(r, x); cout << s * neg_deltas + t * non_neg_deltas << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...