제출 #1258704

#제출 시각아이디문제언어결과실행 시간메모리
1258704pntmatchalatte0309Foehn Phenomena (JOI17_foehn_phenomena)C++20
100 / 100
61 ms7364 KiB
#include <bits/stdc++.h> using namespace std; const long long N = 2000005; long long a[N], d[N]; long long n, q, s, t; int main () { ios_base :: sync_with_stdio(0); cin.tie(0); cin >> n >> q >> s >> t; d[0] = 0; for (int i = 0; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { d[i] = a[i] - a[i-1]; } long long res = 0; for (int i = 1; i <= n; i++) { if (d[i] <= 0) res += t * abs(d[i]); else res -= s * abs(d[i]); } while (q--) { long long l, r, x; cin >> l >> r >> x; if (d[l] <= 0) res -= t * abs(d[l]); else res += s * abs (d[l]); d[l] += x; if (d[l] <= 0) res += t * abs(d[l]); else res -= s * abs(d[l]); if (r>=n) { cout << res << '\n'; continue; } if (d[r+1] <= 0) res -= t * abs (d[r+1]); else res += s * abs (d[r+1]) ; d[r+1] -= x; if (d[r+1] <= 0) res += t * abs (d[r+1]); else res -= s * abs (d[r+1]) ; cout << res << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...