#include <bits/stdc++.h>
using namespace std;
signed main()
{
int n,q,s,t;
cin>>n>>q>>s>>t;
int result = 0;
int a[n+1];
int b[n+1];
a[0] = 0;
for(int i=0;i<=n;i++)
cin>>a[i];
for(int i=1;i<=n;i++)
{
b[i] = a[i-1] - a[i];
if(b[i]<0)
result += b[i]*s;
else
result += b[i]*t;
}
for(int i=0;i<q;i++)
{
int l,r,x;
cin>>l>>r>>x;
if(l)
{
if(b[l]<0)
result -= b[l]*s;
else
result -= b[l]*t;
b[l] -= x;
if(b[l]<0)
result += b[l]*s;
else
result += b[l]*t;
}
if(r<n)
{
if(b[r+1]<0)
result -= b[r+1]*s;
else
result -= b[r+1]*t;
b[r+1] += x;
if(b[r+1]<0)
result += b[r+1]*s;
else
result += b[r+1]*t;
}
cout<<result<<'\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
380 KB |
Output is correct |
2 |
Incorrect |
8 ms |
380 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
702 ms |
3520 KB |
Output is correct |
2 |
Correct |
657 ms |
4052 KB |
Output is correct |
3 |
Incorrect |
676 ms |
4052 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
380 KB |
Output is correct |
2 |
Incorrect |
8 ms |
380 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |