This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
int a[200005];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n, q, l, r, x, i, s, t;
cin >> n >> q >> s >> t;
for (i = 0; i <= n; i++)
cin >> a[i];
ll ans;
while (q--)
{
cin >> l >> r >> x;
for (; l <= r; l++) a[l] += x;
// for (i = 0; i <= n; i++)
// cout << a[i] << " \n"[i == n];
ans = 0;
for (i = 0; i < n; i++)
ans += (a[i] < a[i + 1] ? 1ll * (a[i] - a[i + 1]) * s : 1ll * (a[i] - a[i + 1]) * t);// cout << ans << " ";
cout << ans << 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... |