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>
#define int long long
using namespace std;
const int N = 2e5 + 5;
int n, q, s, t;
int l, r, x;
int a[N];
void solve(int l, int r, int x)
{
a[l-1] += x;
a[r] -= x;
int res = 0;
for (int i = 0;i < n;++i) {
res += (a[i] > 0 ? -s * a[i] : -t * a[i]);
}
cout << res << "\n";
return;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> q >> s >> t;
int prev, nex; cin >> prev;
for (int i = 0;i < n;++i) {
cin >> nex;
a[i] = nex - prev;
prev = nex;
}
for (int i = 0;i < q;++i) {
cin >> l >> r >> x;
solve(l, r, x);
}
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... |