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"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nemeshay ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define allr(pon) pon.rbegin(), pon.rend()
#define all(pon) pon.begin(), pon.end()
#define nosolve cout << "-1\n"
#define YES cout << "YES\n"
#define Yes cout << "Yes\n"
#define pii pair <int, int>
#define OK cout << "OK\n"
#define Ok cout << "Ok\n"
#define NO cout << "NO\n"
#define No cout << "No\n"
#define pf push_front
#define int long long
#define pb push_back
#define sigma signed
#define sc second
#define fr first
using namespace __gnu_pbds;
using namespace std;
const int N = 1e6 + 20, INF = 1e10 + 7;
int a[N], pon[N];
sigma main(){
nemeshay
int n, q, s, t;
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) {
pon[i] = pon[i - 1];
if (a[i] > a[i - 1]) pon[i] -= s * (a[i] - a[i - 1]);
else pon[i] += t * (a[i - 1] - a[i]);
}
while (q--) {
int l, r, x;
cin >> l >> r >> x;
for (int i = l; i <= r; i++) a[i] += x;
for (int i = 1; i <= n; i++) {
pon[i] = pon[i - 1];
if (a[i] > a[i - 1]) pon[i] -= s * (a[i] - a[i - 1]);
else pon[i] += t * (a[i - 1] - a[i]);
}
cout << pon[n] << 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... |