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 <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <unordered_map>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, q, s, t; cin >> n >> q >> s >> t;
vector<ll> c(n + 1);
for(int i = 0; i < n + 1; i++) {
cin >> c[i];
}
for(int i = 0; i < q; i++) {
ll a, b, x;
cin >> a >> b >> x;
for(int i = a; i <= b;i++) {
c[i] += x;
}
ll last = 0;
for(int j = 1; j < n + 1; j++) {
if(c[j] > c[j - 1]) {
last = last + (c[j-1] - c[j]) * -1 * s;
} else {
last = last + (c[j] - c[j - 1]) * t;
}
}
cout << -1 * last << '\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... |