记录编号 |
589409 |
评测结果 |
AAAAAAAAAA |
题目名称 |
焚风现象 |
最终得分 |
100 |
用户昵称 |
┭┮﹏┭┮ |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
1.712 s |
提交时间 |
2024-07-05 12:59:45 |
内存使用 |
39.26 MiB |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
const int N = 2e5+10,M = N<<3;
const ll inf = 1e17;
ll read(){
ll x = 0,f = 1;char c = getchar();
for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
return x * f;
}
int n,m;
ll a[N],S,T;
struct segment{
ll s[M],lm[M],rm[M],la[M];
void pushup(int p){
lm[p] = lm[p<<1],rm[p] = rm[p<<1|1];
s[p] = s[p<<1] + s[p<<1|1];
int ls = rm[p<<1],rs = lm[p<<1|1];
if(ls > rs)s[p] += T * (ls - rs);
else if(rs > ls)s[p] -= S * (rs - ls);
}
void pushdown(int p){
lm[p<<1] += la[p],lm[p<<1|1] += la[p];
rm[p<<1] += la[p],rm[p<<1|1] += la[p];
la[p<<1] += la[p],la[p<<1|1] += la[p];
la[p] = 0;
}
void build(int p,int l,int r){
if(l == r)return lm[p] = rm[p] = a[l],void();
int mid = l + r >> 1;
build(p<<1,l,mid),build(p<<1|1,mid+1,r);
pushup(p);
}
void modify(int p,int l,int r,int L,int R,ll z){
if(L <= l && r <= R)return la[p] += z,lm[p] += z,rm[p] += z,void();
int mid = l + r >> 1;
pushdown(p);
if(L <= mid)modify(p<<1,l,mid,L,R,z);
if(R > mid)modify(p<<1|1,mid+1,r,L,R,z);
pushup(p);
}
}t;
ll ans = 0;
int main(){
freopen("foehn.in","r",stdin);
freopen("foehn.out","w",stdout);
n = read() + 1,m = read(),S = read(),T = read();
for(int i = 1;i <= n;i++)a[i] = read();
t.build(1,1,n);
for(int i = 1;i <= m;i++){
int l = read()+1,r = read()+1;ll z = read();
t.modify(1,1,n,l,r,z);
printf("%lld\n",t.s[1]);
}
return 0;
}