제출 #1279910

#제출 시각아이디문제언어결과실행 시간메모리
1279910peanutFoehn Phenomena (JOI17_foehn_phenomena)C++20
10 / 100
64 ms6340 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, q, s, t; cin >> n >> q >> s >> t; vector<int> a(n+1); for (int &i : a) cin >> i; long long curtemp = 0; vector<long long> diff(n+1); for (int i = 0; i < n; ++i) { diff[i] = a[i] - a[i+1]; if (diff[i] < 0) curtemp += 1LL*s*diff[i]; else curtemp += 1LL*t*diff[i]; } while (q--) { int l, r, x; cin >> l >> r >> x; if (l != 0) { if (diff[l-1] >= 0 && diff[l-1] - x < 0) { curtemp -= 1LL*t*diff[l-1]; curtemp += 1LL*s*(diff[l-1]-x); } else curtemp -= 1LL*((diff[l-1] < 0) ? s : t)*x; diff[l-1] -= x; } if (r != n) { if (diff[r] < 0 && diff[r] + x >= 0) { curtemp -= 1LL*s*diff[r]; curtemp += 1LL*t*(diff[r]+x); } else curtemp += 1LL*((diff[r] < 0) ? s : t)*x; diff[r] += x; } cout << curtemp << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...