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;
ll n, q, S, T, ans;
vector<ll> input, v;
void query(int x, ll val){
if(v[x] > 0) ans += v[x] * S;
else ans += v[x] * T;
// cout << ans << " ";
v[x] += val;
if(v[x] > 0) ans -= v[x] * S;
else ans -= v[x] * T;
// cout << ans << "\n";
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> q >> S >> T; input.resize(n+1); v.resize(n+1);
for(int i=0; i<=n; i++) cin >> input[i];
for(int i=1; i<=n; i++) query(i, input[i] - input[i-1]);
while(q--){
ll s, e, x; cin >> s >> e >> x;
query(s, x);
if(e < n) query(e+1, -x);
cout << ans << "\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... |