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;
#define ll long long
const int nx=2e5+5;
ll v[nx], d[nx], n, q, s, t, l, r, k, ans, tmp;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>q>>s>>t>>tmp;
for (int i=1; i<=n; i++) cin>>v[i], d[i]=v[i]-v[i-1];
for (int i=1; i<=n; i++) ans=(d[i]>0)?ans+d[i]*s:ans+d[i]*t;
while (q--)
{
cin>>l>>r>>k;
ans=(d[l]>0)?ans-d[l]*s:ans-d[l]*t;
d[l]+=k;
ans=(d[l]>0)?ans+d[l]*s:ans+d[l]*t;
if (r==n)
{
cout<<-ans<<'\n';
continue;
}
ans=(d[r+1]>0)?ans-d[r+1]*s:ans-d[r+1]*t;
d[r+1]-=k;
ans=(d[r+1]>0)?ans+d[r+1]*s:ans+d[r+1]*t;
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... |