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 pld pair<long double, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define ff first
#define ss second
#define SZ(x) ((int)(x).size())
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 2e5+100;
int N, Q;
ll S, T, a[MAXN];
void read(){
cin >> N >> Q >> S >> T;
for(int i = 0; i <= N; i++){
cin >> a[i];
}
}
ll calcola(){
int t = 0;
for(int i = 0; i < N; i++){
if(a[i] < a[i+1])
t -= (a[i+1] - a[i]) * S;
else if(a[i] > a[i+1])
t += (a[i] - a[i+1]) * T;
}
return t;
}
void solve(){
read();
while(Q--){
int l, r, x;
cin >> l >> r >> x;
for(int i = l; i <= r; i++) a[i] += x;
cout << calcola() << "\n";
}
}
int main(){
ios_base::sync_with_stdio(false);
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... |