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];
ll dist[200200];
ll x,y;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> q >> s >> t;
cin >> a[0];
for(int i=1; i<=n; i++) {
cin >> a[i];
dist[i] = a[i] - a[i-1];
if(dist[i] > 0) {
x += dist[i];
}
else {
y += dist[i];
}
}
for(int i=1; i<=q; i++) {
cin >> l >> r >> h;
if(dist[l] > 0) {
x -= dist[l];
}
else {
y -= dist[l];
}
if(dist[l] + h > 0) {
x += dist[l] + h;
}
else {
y += dist[l] + h;
}
dist[l] += h;
if(r != n) {
if(dist[r+1] > 0) {
x -= dist[r+1];
}
else {
y -= dist[r+1];
}
if(dist[r+1] - h > 0) {
x += dist[r+1] - h;
}
else {
y += dist[r+1] - h;
}
dist[r+1] -= h;
}
cout << abs(y)*t - x*s << 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... |