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 <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, q, s, t;
cin >> n >> q >> s >> t;
n++;
vector<int> a(n);
auto solve = [&]() {
int ans = 0;
for (int i = 0; i + 1 < n; i++) {
if (a[i] <= a[i + 1]) ans += (a[i + 1] - a[i]) * s;
else ans += (a[i + 1] - a[i]) * t;
}
return ans;
};
for (auto &x : a) {
cin >> x;
}
while (q--) {
int l, r, x;
cin >> l >> r >> x;
for (int i = l; i <= r; i++) {
a[i] += x;
}
cout << -solve() << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |