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
#define fi first
#define se second
#define pll pair<ll, ll>
#define pb push_back
#define bp pop_back
#define ades ios_base::sync_with_stdio(false); cin.tie(NULL);
ll N, Q, s, t, a[2010], L[2010], R[2010], P;
int main(){
cin >> N >> Q >> s >> t;
N++;
for(int i = 1; i<= N; i++){
cin >> a[i];
// dif[i] = a[i]-a[i-1];
// S[i] = S{i-1};
// T[i] = T[i-1];
// if(a[i] > a[i-1]){
// S[i] += dif[i];
// }
// else{
// T[i] += dif[i];
// }
}
for(int i = 1; i<= N; i++){
cout << a[i] << ' ';
}
cout << endl;
for(int i = 1; i<= Q; i++){
cin >> L[i] >> R[i] >> P;
ll total = 0;
L[i]++;
R[i]++;
for(int j = 1; j<= N; j++){
if(L[i]<=j && j<= R[i]){
a[j] += P;
}
if(a[j] > a[j-1]){
total -= (a[j]-a[j-1])*s;
}
else{
total += abs(a[j]-a[j-1])*t;
}
// cout << a[j] << ' ';
}
// cout << endl;
cout << total << 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... |