#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[200100];
ll t[200100];
int n, q, S, T;
void build(int v, int l, int r){
if(l == r){
if(a[l] < 0) t[v] = -a[l] * T;
else t[v] = -a[l] * S;
return;
}
int mid=(l+r)/2;
build(v+v, l, mid);
build(v+v+1, mid+1, r);
t[v] = t[v + v] + t[v+v+1];
}
void upd(int v, int l, int r, int pos, int x){
if(l == r){
a[l] += x;
if(a[l] < 0) t[v] = -a[l] * T;
else t[v] = -a[l] * S;
return;
}
int mid = (l + r)/2;
if(mid >= pos) upd(v+v, l, mid, pos, x);
else upd(v+v+1, mid+1, r, pos, x);
t[v] = t[v+v] + t[v+v+1];
}
int main(){
cin>>n>>q>>S>>T;
for(int i=0; i<=n; i++){
cin>>a[i];
}
for(int i=n; i>=1; i--) a[i] = a[i] - a[i - 1];
build(1, 1, n);
//cout<<t[1]<<'\n';
for(int i=1; i<=q; i++){
int l, r, x;
cin>>l>>r>>x;
upd(1, 1, n, l, x);
if(r + 1 <= n) upd(1, 1, n, r + 1, -x);
cout<<t[1]<<'\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2392 KB |
Output is correct |
2 |
Correct |
5 ms |
2396 KB |
Output is correct |
3 |
Incorrect |
4 ms |
2596 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
39 ms |
6480 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2392 KB |
Output is correct |
2 |
Correct |
5 ms |
2396 KB |
Output is correct |
3 |
Incorrect |
4 ms |
2596 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |