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 unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
void solve(){
ll n,quer,s,t; cin >> n >> quer >> s >> t;
ll b[n+1];
for(int i = 0;i<=n;i++) cin >> b[i];
ll ant = 0;
for(int i = 0;i<quer;i++){
int l,r,x; cin >> l >> r >> x;
for(int j = l;j<=r;j++){
b[j]+=x;
}
ant = 0;
for(int j = 1;j<=n;j++){
if(b[j-1] >= b[j]) ant+=(t*abs(b[j-1]-b[j]));
else ant -= (s*abs(b[j-1]-b[j]));
}
cout << ant << "\n";
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(nullptr);
cout << fixed << setprecision(8);
int t = 1;
// cin >> t;
while(t){
solve();
t--;
cout << "\n";
}
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... |