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;
typedef long long ll;
typedef pair<int, int> II;
const int N = 2e5 + 5, logN = 20;
const int MOD = 1e9 + 7;
const ll INF = 1e9;
int n, q, s, t, a[N];
ll ans = 0, dif[N];
void update(int i, ll val){
if(dif[i] > 0) ans += dif[i] * 1ll * s;
else ans += dif[i] * 1ll * t;
dif[i] = val;
if(dif[i] > 0) ans -= dif[i] * 1ll * s;
else ans -= dif[i] * 1ll * t;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> q >> s >> t;
for(int i = 0; i <= n; i ++) cin >> a[i];
for(int i = 1; i <= n; i ++){
update(i, a[i] - a[i - 1]);
}
while(q --){
int l, r, x;
cin >> l >> r >> x;
update(l, dif[l] + x);
if(r + 1 <= n) update(r + 1, dif[r + 1] - x);
cout << ans << "\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... |