제출 #651812

#제출 시각아이디문제언어결과실행 시간메모리
651812lunchboxFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
139 ms12268 KiB
/*
 author: lunchbox
 problem link: https://oj.uz/problem/view/JOI17_foehn_phenomena
*/
#include <bits/stdc++.h>
using namespace std;

int main() {
 ios::sync_with_stdio(0), cin.tie(0);
 int n, q, s, t; cin >> n >> q >> s >> t, n++;
 vector<int> a(n); for (int& x : a) cin >> x;
 vector<long long> d(n - 1);
 long long c = 0;
 auto upd = [&](int i, int x) {
  c -= d[i] * (d[i] >= 0 ? t : s);
  d[i] += x;
  c += d[i] * (d[i] >= 0 ? t : s);
 };
 for (int i = 0; i < n - 1; i++) upd(i, a[i] - a[i + 1]);
 while (q--) {
  int l, r, x; cin >> l >> r >> x;
  upd(l - 1, -x);
  if (r < n - 1) upd(r, +x);
  cout << c << '\n';
 }
 return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...