Submission #1165230

#TimeUsernameProblemLanguageResultExecution timeMemory
1165230TsaganaFoehn Phenomena (JOI17_foehn_phenomena)C++20
100 / 100
190 ms7348 KiB
#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second

using namespace std;

int a[200010];
int d[200010];
int n, q, s, t;

int calc(int i) {return abs(d[i]) * (d[i] < 0 ? t : -s);}

void solve () {
	cin >> n >> q >> s >> t;
	
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		cin >> a[i];
		if (i) {
			d[i] = a[i] - a[i-1];
			ans += calc(i);
		}
	}

	while (q--) {
		int l, r, k;
		cin >> l >> r >> k;

		ans -= calc(l);
		d[l] += k;
		ans += calc(l);

		if (r < n) {
			ans -= calc(r+1);
			d[r+1] -= k;
			ans += calc(r+1);
		}

		cout << ans << '\n';
	}
}
signed main() {IOS solve(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...