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>
#define ll long long
#define int long long
#define pb push_back
#define F first
#define S second
using namespace std;
const long long N = 3e5+10;
const long long mod = 1e9+7;
const long long inf = 1e18;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,Q,s,t;
cin >> n >> Q >> s >> t;
vector<int>a(n+1);
for(int i=0;i<=n;i++) cin >> a[i];
while(Q--) {
int l,r,x;
cin >> l >> r >> x;
for(int i=l;i<=r;i++) a[i] += x;
int res = 0;
for(int i=1;i<=n;i++) {
if(a[i-1] < a[i]) res -= (a[i]-a[i-1])*s;
else res += (a[i-1]-a[i])*t;
}
cout << res << '\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... |