#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
float db,y[100000],x[1000000];
long long t,i,l,n,mod=1000000007,c,a,m,e,d,b,j,w[300005],f[300005],z[300005],g=0,q,p,r[300005],h[200005],o[1001][1001];
map<ll,ll>blp;
set<ll>st;
string s,sa[200005],ta[200005],sn,sm,sk,k[200005],cr,sx,sy;
pair<ll,ll>pr[30005];
char ch[200005];
vector<ll>ret;
cin>>n>>m>>a>>b;
for (i=0; i<=n; i++){
cin>>z[i];
}
for (i=1; i<=m; i++){
cin>>f[i]>>r[i]>>h[i];
}
for (i=1; i<=n; i++){
if (z[i]>z[i-1]){
w[i]=w[i-1]-a*(z[i]-z[i-1]);
}
else {
w[i]=w[i-1]+b*(z[i-1]-z[i]);
}
}
if (a==b){
for (i=1; i<=m; i++){
if (r[i]!=n){
cout<<w[n]<<endl;
}
else {
w[n]=w[n]-a*h[i];
cout<<w[n]<<endl;
}
}
return 0;
}
for (i=1; i<=m; i++){
for (j=f[i]; j<=r[i]; j++){
z[j]=z[j]+h[i];
}
for (j=1; j<=n; j++){
if (z[j]>z[j-1]){
w[j]=w[j-1]-a*(z[j]-z[j-1]);
}
else {
w[j]=w[j-1]+b*(z[j-1]-z[j]);
}
}
cout<<w[n]<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |