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 ll long long
int main() {
int n, q, s, t;
cin >> n >> q >> s >> t;
vector<ll> a(n+1);
for (int i = 0; i <= n; i++) {
cin >> a[i];
}
vector<ll> temp(n+1);
while (q--) {
int l, r, x;
cin >> l >> r >> x;
for (int i = l; i <= r; i++) {
a[i] += x;
}
for (int i = 0; i < n; i++) {
if (a[i] < a[i+1]) {
temp[i+1] = temp[i]-(a[i+1]-a[i])*s;
}
else {
temp[i+1] = temp[i]+(a[i]-a[i+1])*t;
}
}
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... |