#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll n,q,s,t; cin>>n>>q>>s>>t;
ll a[n+1],b[n];
ll wind=0;
for (ll i=0;i<=n;i++) {
cin>>a[i];
if (i>0) {
b[i-1]=a[i]-a[i-1];
if (b[i-1]>0) {
wind-=s*b[i-1];
} else {
wind+=t*abs(b[i-1]);
}
}
}
while(q--) {
ll l,r,x; cin>>l>>r>>x;
b[l-1]+=x;
ll i=b[l-1]-x, j=b[l-1];
if (i>0 && j>0) {
wind+=s*(i-j);
} else if (j<=0 && i<=0) {
wind+=t*(i-j);
} else {
wind-=t*abs(i);
wind-=s*abs(j);
}
if (r<n) {
b[r]-=x;
i=b[r]+x, j=b[r];
if (i>0 && j>0) {
wind+=s*(i-j);
} else if (j<=0 && i<=0) {
wind+=t*(i-j);
} else {
wind-=t*abs(i);
wind-=s*abs(j);
}
}
cout<<wind<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
266 ms |
9812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |