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
ll n,q,s,t,ans,l,r,h;
ll a[200200],b[200200];
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(q <= 2000 && n <= 2000) {
for(int i=1; i<=q; i++) {
cin >> l >> r >> h;
for(int j=l; j<=r; j++) {
a[j] += h;
}
ans = 0;
for(int j=1; j<=n; j++) {
if(a[j] > a[j-1]) {
ans -= s*(a[j] - a[j-1]);
}
else {
ans += t*(a[j-1] - a[j]);
}
}
cout << ans << endl;
}
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |