This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define _CRT_SECURE_NO_WARNINGS
#ifdef _DEBUG
#define FILE_IN "input.txt"
#define FILE_OUT "output.txt"
#endif
#include <iostream>
#include <cstdlib>
#include <climits>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
void openFiles() {
#ifdef _DEBUG
assert(freopen(FILE_IN, "r", stdin));
assert(freopen(FILE_OUT, "w", stdout));
#endif
}
vector<ll> a;
int main() {
openFiles();
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, q, s, t;
cin >> n >> q >> s >> t;
n++;
a.resize(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int j = 0; j < q; j++) {
int l, r;
ll x;
cin >> l >> r >> x;
for (int i = l; i <= r; i++) {
a[i] += x;
}
ll res = 0;
for (int i = 1; i < n; i++) {
ll diff = abs(a[i] - a[i - 1]);
if (a[i] > a[i - 1]) {
res -= s * diff;
}
else {
res += t * diff;
}
}
cout << res << "\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... |