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 int
int main(){
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll n,q,s,t; cin>>n>>q>>s>>t;
ll a[n+1],b[n];
ll wind=0;
for (ll i=0;i<=n;i++) {
cin>>a[i];
if (i>0) {
b[i-1]=a[i]-a[i-1];
if (b[i-1]>0) {
wind-=s*b[i-1];
} else {
wind-=t*b[i-1];
}
cout<<b[i-1]<<" ";
}
}
cout<<endl;
cout<<wind<<endl;
while(q--) {
ll l,r,x; cin>>l>>r>>x;
if (x>0) {
if (b[l-1]>0) {
wind-=s*x;
} else {
if (b[l-1]+x<=0) {
wind-=t*x;
} else {
wind+=t*b[l-1];
wind-=s*(x+b[l-1]);
}
}
} else if (x<0) {
if (b[l-1]+x>0) {
wind-=s*x;
} else {
if (b[l-1]<=0) {
wind-=t*x;
} else {
wind+=t*b[l-1];
wind-=s*(x+b[l-1]);
}
}
}
b[l-1]+=x;
if (x<0) {
if (b[r]>0) {
wind-=s*x;
} else {
if (b[r]+x<=0) {
wind-=t*x;
} else {
wind+=t*b[r];
wind-=s*(x+b[r]);
}
}
} else if (x>0) {
if (b[r]+x>0) {
wind-=s*x;
} else {
if (b[r]<=0) {
wind-=t*x;
} else {
wind+=t*b[r];
wind-=s*(x+b[r]);
}
}
}
b[r]-=x;
for (auto y:b) {
cout<<y<<" ";
}
cout<<endl;
cout<<wind<<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... |