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 ll long long
#define ld double
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define pb emplace_back
#define X first
#define Y second
const int N = 2e5 + 5;
typedef pair<int,int> ii;
int a[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, q; cin >> n >> q;
int S, T; cin >> S >> T;
for(int i = 0 ; i <= n ; ++i) cin >> a[i];
for(int i = 1 ; i <= n ; ++i) a[i - 1] -= a[i];
ll temp = 0;
for(int i = 0 ; i < n ; ++i)
temp += 1ll * a[i] * (a[i] > 0 ? T : S);
auto add = [&](int p,int x) {
if (p == n)
return;
temp -= 1ll * a[p] * (a[p] > 0 ? T : S); a[p] += x;
temp += 1ll * a[p] * (a[p] > 0 ? T : S);
};
for(int i = 0 ; i < q ; ++i) {
int l; cin >> l; --l;
int r; cin >> r;
int x; cin >> x;
add(l,-x);
add(r, x);
cout << temp << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |