This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N,Q; ll S,T; cin >> N >> Q >> S >> T;
vector<ll> arr(N+1);
for(auto &x : arr) cin >> x;
vector<ll> wind(N);
for(int i = 0;i<N;++i) wind[i] = arr[i]-arr[i+1];
auto upd = [&](int ind){
if(wind[ind] < 0) return S*wind[ind];
else return T*wind[ind];
};
ll ans = 0;
for(int i = 0;i<N;++i) ans += upd(i);
while(Q--){
int l,r; ll val; cin >> l >> r >> val;
ans -= upd(l-1);
wind[l-1] -= val;
ans += upd(l-1);
if(r < N){
ans -= upd(r);
wind[r] += val;
ans += upd(r);
}
cout << ans << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |