제출 #1326418

#제출 시각아이디문제언어결과실행 시간메모리
1326418hoangtien69Foehn Phenomena (JOI17_foehn_phenomena)C++20
100 / 100
76 ms7232 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int MAXN = 2e5 + 5; int n, q, s, t; int a[MAXN]; int d[MAXN]; int ans = 0; int tinh(int x) { if (x > 0) { return -x * s; } else { return -x * t; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> q >> s >> t; for (int i = 0; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { d[i] = a[i] - a[i - 1]; } for (int i = 1; i <= n; i++) { ans += tinh(d[i]); } while(q--) { int l, r, k; cin >> l >> r >> k; ans -= tinh(d[l]); d[l] += k; ans += tinh(d[l]); if (r < n) { ans -= tinh(d[r + 1]); d[r + 1] -= k; ans += tinh(d[r + 1]); } cout << ans << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...