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 rall(v) v.rbegin(), v.rend()
#define all(v) v.begin(), v.end()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define endl '\n'
#define f first
#define s second
#define PI 3.14159265358979323846
#define ll128 __ll128_t
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef long long ll;
const int INF = (1<<30), M = 5*1e5+7, MOD = 1000000007;
ll a[M], tmp[M], n, q, s, t;
ll calc() {
for (int i = 0; i < n; i++) {
tmp[i+1] = tmp[i];
if (a[i] < a[i+1]) tmp[i+1] -= abs(a[i]-a[i+1])*s;
else tmp[i+1] += abs(a[i]-a[i+1])*t;
} return a[n];
}
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
srand(time(0));
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; i++) {
cin >> a[i];
} calc();
while (q--) {
int l, r, x;
cin >> l >> r >> x;
for (int i = l; i <= r; i++) a[i] += x;
calc();
cout << tmp[n] << 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... |