#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll S, T;
// Bitta farq uchun harorat o'zgarishini hisoblash
ll calc(ll d) {
if (d > 0) return -d * S;
return -d * T;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N, Q;
cin >> N >> Q >> S >> T;
vector<ll> A(N + 1);
vector<ll> D(N + 2, 0);
ll current_temp = 0;
for (int i = 0; i <= N; i++) {
cin >> A[i];
if (i > 0) {
D[i] = A[i] - A[i-1];
current_temp += calc(D[i]);
}
}
for (int j = 0; j < Q; j++) {
int L, R;
ll X;
cin >> L >> R >> X;
// L-nuqtadagi o'zgarish
current_temp -= calc(D[L]);
D[L] += X;
current_temp += calc(D[L]);
// R+1 nuqtadagi o'zgarish (agar u N dan katta bo'lmasa)
if (R + 1 <= N) {
current_temp -= calc(D[R+1]);
D[R+1] -= X;
current_temp += calc(D[R+1]);
}
cout << current_temp << "\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... |