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 <iostream>
using namespace std;
long long v[200003], dif[200003];
int main()
{
int n, q, s, t, a, b, c;
cin>>n>>q>>s>>t;
long long temp=0;
cin>>v[0];
for(int i=1; i<=n; i++)
{
cin>>v[i];
dif[i]=v[i]-v[i-1];
temp-=dif[i] *(dif[i] >0 ? s:t);
}
while(q--)
{
cin>>a>>b>>c;
temp+=dif[a] *(dif[a]>0 ? s:t);
dif[a]+=c;
temp-=dif[a] *(dif[a]>0 ? s:t);
if(b!=n)
{
temp+=dif[b+1] *(dif[b+1]>0 ? s:t);
dif[b+1]-=c;
temp-=dif[b+1] *(dif[b+1]>0 ? s:t);
}
cout<<temp<<'\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... |