Submission #211784

#TimeUsernameProblemLanguageResultExecution timeMemory
211784skytectFoehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
196 ms11000 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

int n, q, s, t;
ll d[200000], up = 0, down = 0;

void update(int p, ll x) {
	if (p < 1 or p > n) return;

	if (d[p] > 0)
		up -= d[p];
	else
		down += d[p];

	d[p] += x;

	if (d[p] > 0)
		up += d[p];
	else
		down -= d[p];
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> q >> s >> t;

	int last = 0;
	for (int i = 0; i <= n; ++i) {
		cin >> d[i];

		d[i] -= last;

		if (d[i] > 0)
			up += d[i];
		else
			down -= d[i];

		last += d[i];
	}

	for (int i = 0; i < q; ++i) {
		int l, r, x;
		cin >> l >> r >> x;

		update(l, x);
		update(r + 1, -x);

		cout << t * (ll)down - s * (ll)up << '\n';
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...