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>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
ll n,q,s,t;
cin >> n >> q >> s >> t;
vector<ll> a(n+1,0),d(n+1,0);
for (int i = 0;i<=n;i++){
cin >> a[i];
if (i) d[i] = a[i]-a[i-1];
}
auto f = [&s,&t](ll i){return i>0?i*s:i*t;};
ll ans = 0;
for (int i = 1;i<=n;i++){
ans -= f(d[i]);
}
while (q--){
ll l,r,x;
cin >> l >> r >> x;
ans += f(d[l]);
d[l]+=x;
ans -= f(d[l]);
if (r<n){
ans+=f(d[r+1]);
d[r+1]-=x;
ans-=f(d[r+1]);
}
cout << ans << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |