Submission #51486

#TimeUsernameProblemLanguageResultExecution timeMemory
51486Arashi1224Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
794 ms5944 KiB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
ll n, s, q ,t, a[200005], ans = 0, l, r, x, temp;

int main() {
	cin >> n >> q >> s >> t;
	cin >> temp;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i - 1] = temp - a[i];
		temp = a[i];
		ans += a[i - 1] * (a[i - 1] < 0 ? s : t);
	}
	for(int i = 0; i < q; i++) {
		cin >> l >> r >> x;
		l--;
		ans -= a[l] * (a[l] < 0 ? s : t);
		a[l] -= x;
		ans += a[l] * (a[l] < 0 ? s : t);
		if(r != n) {
			ans -= a[r] * (a[r] < 0 ? s : t);
			a[r] += x;
			ans += a[r] * (a[r] < 0 ? s : t);
		}
		cout << ans << endl;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...