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 int long long
#define endl '\n'
const int sz = 2e5 + 5;
vector<int> qr[sz];
long long a[sz];
int n, q, s, t;
// ------------ SUBTASKS ------------
namespace SUB1{
bool ok(){
return (n <= 2000 && q <= 2000);
}
void solve(){
for(int i=1; i<=q; ++i){
int l = qr[i][0], r = qr[i][1], x = qr[i][2];
int ans = 0;
for(int j=1; j<=n; ++j){
if(j >= l && j <= r){
a[j] += x;
}
if(a[j-1] < a[j]){
ans -= (a[j] - a[j-1])*s;
}
else{
ans += (a[j-1] - a[j])*t;
}
}
cout<<ans<<endl;
}
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("main.inp","r",stdin);
//freopen("main.out","w",stdout);
cin>>n>>q>>s>>t;
for(int i=0; i<=n; ++i){
cin>>a[i];
}
for(int i=1; i<=q; ++i){
int l, r, x;
cin>>l>>r>>x;
qr[i] = {l, r, x};
}
SUB1::solve();
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... |