#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> ii;
const int INF = 1e9;
const int nx = 200005;
int i, j ,k;
int n, q, S, T, alt[nx], temp[nx];
int main(int argc, char **argv){
cin.tie(NULL)->sync_with_stdio(false);
cin >> n >> q >> S >> T;
for(int i=0; i<=n; i++) cin >> alt[i];
while(q--){
int l, r, x;
cin >> l >> r >> x;
for(int i=l; i<=r; i++){
alt[i]+=x;
}
for(int i=0; i<n; i++){
if(alt[i]<alt[i+1]) temp[i+1] = temp[i]-S*(alt[i+1]-alt[i]);
else temp[i+1] = temp[i]+T*(alt[i]-alt[i+1]);
}
cout << temp[n] << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |