This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define all(v) (v).begin(),(v).end()
using namespace std;
const int N = 200005;
int n, q, s, t;
int a[N];
ll b[N];
ll get(ll x) {
if (x < 0) return x * s;
else return x * t;
}
int main() {
ios_base :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; i++) {
cin >> a[i];
}
ll res = 0;
for (int i = 1; i <= n; i++) {
b[i] = -a[i] + a[i - 1];
res += get(b[i]);
}
while(q--) {
int l, r, x;
cin >> l >> r >> x;
res -= get(b[l]);
b[l] -= x;
res += get(b[l]);
if (r < n) {
res -= get(b[r + 1]);
b[r + 1] += x;
res += get(b[r + 1]);
}
cout << res << endl;
}
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... |