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 all(x) x.begin(), x.end()
#define siz(x) int(x.size())
#define ll long long
#define ar array
#define vt vector
#define inf INT_MAX
#define lnf LLONG_MAX
const int nxm = int(2e3) + 7;
ll n, q, s, t, a[nxm];
namespace sub1 {
ll l, r, x;
void exe() {
while (q--) {
cin >> l >> r >> x;
for (int i = l; i <= r; ++i) {
a[i] += x;
}
ll ans = 0;
for (int i = 1; i <= n; ++i) {
if (a[i] > a[i - 1]) {
ans -= (a[i] - a[i - 1]) * s;
} else {
ans += (a[i - 1] - a[i]) * t;
}
}
cout << ans << "\n";
}
}
};
int subtask() {
if (n <= 2000 && q <= 2000) {
return 1;
}
return 2;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; ++i) {
cin >> a[i];
}
if (subtask() == 1) {
sub1::exe();
}
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... |