제출 #996861

#제출 시각아이디문제언어결과실행 시간메모리
996861toast12Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
451 ms13140 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int n, q, s, t; cin >> n >> q >> s >> t; vector<ll> a(n+1); for (int i = 0; i <= n; i++) { cin >> a[i]; } vector<ll> diff(n); ll pos = 0, neg = 0; for (int i = 1; i <= n; i++) { diff[i-1] = a[i]-a[i-1]; if (diff[i-1] < 0) neg += abs(diff[i-1]); else pos += diff[i-1]; } while (q--) { int l, r, x; cin >> l >> r >> x; l--; if (diff[l] < 0) neg -= abs(diff[l]); else pos -= abs(diff[l]); diff[l] += x; if (r < n) { if (diff[r] < 0) neg -= abs(diff[r]); else pos -= abs(diff[r]); diff[r] -= x; } if (diff[l] < 0) neg += abs(diff[l]); else pos += diff[l]; if (r < n) { if (diff[r] < 0) neg += abs(diff[r]); else pos += diff[r]; } cout << neg*t - pos*s << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...