Submission #765426

#TimeUsernameProblemLanguageResultExecution timeMemory
765426NK_Foehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
97 ms5088 KiB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'

using ll = long long;
template<class T> using V = vector<int>;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	
	int N, M, S, T; cin >> N >> M >> S >> T;
	V<ll> A(N+1); for(auto& x : A) cin >> x;

	ll ans = 0;
	V<ll> D(N); for(int i = 0; i < N; i++) D[i] = A[i] - A[i + 1];

	auto upd = [&](int x, ll t) {
		if (D[x] < 0) ans += S * t * D[x];
		else ans += T * t * D[x];
	};

	for(int i = 0; i < N; i++) upd(i, +1);

	for(int q = 0; q < M; q++) {
		int l, r, x; cin >> l >> r >> x;
		{
			upd(l - 1, -1);
			D[l - 1] -= x;
			upd(l - 1, +1);
		}

		if (r < N) {
			upd(r, -1);
			D[r] += x;
			upd(r, +1);
		}

		cout << ans << nl;
	}

    return 0;
}


#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...