#include<bits/stdc++.h>
#include<string.h>
#include <algorithm>
#include <stdlib.h>
#define ll long long
using namespace std;
ll k[500006],a,b,c,d,e,f,m,i,j,n,h,g,l,r,ka,p,q[200005],t[200005];
map<ll,ll> maa,mii,mee;
vector<ll> vas[25],vis,vii;
int main(){
cin>>a>>ka>>c>>d;
cin>>h;
for(i=1 ; i<=a ; i++){
cin>>g;
k[i]=g-h;
h=g;
}
h=0;
for(i=1 ; i<=a ; i++){
if(k[i]>0){
h-=c*(k[i]);
}
else{
h+=d*(-k[i]);
}
}
while(ka--){
cin>>e>>f>>g;
if(k[e]>0){
h+=c*(k[e]);
}
else{
h+=d*k[e];
}
if(f<a){
if(k[f+1]>0){
h+=c*k[f+1];
}
else{
h+=d*k[f+1];
}
}
k[e]+=g;
if(k[e]>0){
h-=c*k[e];
}
else{
h-=d*k[e];
}
if(f<a){
k[f+1]-=g;
if(k[f+1]>0){
h-=c*k[f+1];
}
else{
h-=d*k[f+1];
}
}
cout<<h<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |