Submission #1208753

#TimeUsernameProblemLanguageResultExecution timeMemory
1208753andrejikusFoehn Phenomena (JOI17_foehn_phenomena)C++20
30 / 100
6 ms328 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...); }
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

const int N = 2003;
ll a[N];


void solve() {
    ll n, q, s, t; cin >> n >> q >> s >> t;
    for (int i = 0; i <= n; i++) cin >> a[i];

    while (q--) {
        ll l, r, x; cin >> l >> r >> x;
        for (int j = l; j <= r; j++)
            a[j] += x;
        ll ans = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i-1] < a[i])
                ans -= (a[i]-a[i-1])*s;
            else
                ans += (a[i-1]-a[i])*t;
        }

        cout << ans << "\n";
    }
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
	int t=1; //cin >> t;
	while (t--) {
        solve();
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...