제출 #661090

#제출 시각아이디문제언어결과실행 시간메모리
661090sandry24Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
107 ms13060 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; #define pb push_back #define mp make_pair #define f first #define s second void solve(){ ll n, q, s, t, pos = 0, neg = 0; cin >> n >> q >> s >> t; vector<ll> a(n+1), diff(n+1); for(int i = 0; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++){ diff[i] = a[i] - a[i-1]; if(a[i] >= a[i-1]) pos += diff[i]; else neg += -diff[i]; } //cout << neg*t - pos*s << '\n'; for(int i = 0; i < q; i++){ ll l, r, x; cin >> l >> r >> x; if(diff[l] < 0) neg -= -diff[l]; else pos -= diff[l]; diff[l] += x; if(diff[l] < 0) neg += -diff[l]; else pos += diff[l]; if(r != n){ if(diff[r+1] < 0) neg -= -diff[r+1]; else pos -= diff[r+1]; diff[r+1] -= x; if(diff[r+1] < 0) neg += -diff[r+1]; else pos += diff[r+1]; } cout << neg*t - pos*s << '\n'; } } int main() { ios::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...