This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define ull unsigned long long
#define sqrt sqrtl
#define cbrt cbrtl
#define pow powl
#define floor floorl
#define ceil ceill
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define dbg puts("dbg");
#define outp(x) cout << #x << " = " << (x) << endl
#define dah '\n'
#define all(x) (x).begin(), (x).end()
#define test int t; cin >> t; while(t--){solve();}
#define MOD 998244353
int n, q, s, t, a[200007];
void solve(){
cin >> n >> q >> s >> t;
for(int i=0; i<=n; i++){
cin >> a[i];
}
int suhuAwal = 0;
for(int i=1; i<=n; i++){
if(a[i-1] < a[i]) suhuAwal -= s*(a[i]-a[i-1]);
else if(a[i-1] > a[i]) suhuAwal += t*(a[i-1]-a[i]);
}
for(int i=1; i<=q; i++){
int l, r, x; cin >> l >> r >> x;
for(int j=l; j<=r; j++){
a[j] += x;
}
suhuAwal = 0;
for(int j=1; j<=n; j++){
if(a[j-1] < a[j]) suhuAwal -= s*(a[j]-a[j-1]);
else if(a[j-1] > a[j]) suhuAwal += t*(a[j-1]-a[j]);
}
cout << suhuAwal << dah;
}
}
int32_t main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
solve();
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... |