제출 #784513

#제출 시각아이디문제언어결과실행 시간메모리
784513christinelynnFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
98 ms13132 KiB
# include <bits/stdc++.h> # define int long long # define vi vector<int> # define pb push_back # define pii pair<int, int> # define fi first # define se second # define endl '\n' # define jess ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; int n, q, s, t, a[200005], dif[200005]; void solve() { cin >> n >> q >> s >> t; int pos=0, neg=0; for(int i=0; i<=n; i++) { cin >> a[i]; if(i>=1) { dif[i]=a[i]-a[i-1]; if(dif[i]<=0) neg+=dif[i]; if(dif[i]>0) pos+=dif[i]; } } for(int i=1; i<=q; i++) { // cout << "idx " << i << endl; // cout << "bef " << pos << " " << neg << endl; int l, r, x; cin >> l >> r >> x; if(dif[l]+x>0) { if(dif[l]<=0) { neg-=dif[l]; } else { pos-=dif[l]; } dif[l]+=x; pos+=dif[l]; } else { if(dif[l]<=0) neg-=dif[l]; else pos-=dif[l]; dif[l]+=x; neg+=dif[l]; } r++; if((dif[r]-x>0) && (r<=n)) { if(dif[r]<=0) { neg-=dif[r]; } else { pos-=dif[r]; } dif[r]-=x; pos+=dif[r]; } else if (r<=n){ if(dif[r]<=0) neg-=dif[r]; else pos-=dif[r]; dif[r]-=x; neg+=dif[r]; } // cout << "aft " << pos << " " << neg << endl; cout << (-1)*neg*t - pos*s << endl; } } signed main() { jess; solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...