比赛 |
2024暑假C班集训5 |
评测结果 |
TTTTTTTTTT |
题目名称 |
焚风现象 |
最终得分 |
0 |
用户昵称 |
┭┮﹏┭┮ |
运行时间 |
10.000 s |
代码语言 |
C++ |
内存使用 |
56.09 MiB |
提交时间 |
2024-07-05 09:58:17 |
显示代码纯文本
#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-13.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;
}