제출 #916627

#제출 시각아이디문제언어결과실행 시간메모리
916627vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
325 ms11460 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mll map<ll, ll>
#define fi first
#define se second

ll n, q, s, t, l, r, d, add, sub, temp;
ll a[200001];

void f(ll p, ll d) {
	if (p < 1 or p > n) {
		return;
	}
	if (a[p] > 0) {
		add -= a[p];
	} else {
		sub += a[p];
	}
	a[p] += d;
	if (a[p] > 0) {
		add += a[p];
	} else {
		sub -= a[p];
	}
}

int main() {
	fastio;
	cin >> n >> q >> s >> t;
	for (int i = 0; i <= n; i++) {
		cin >> a[i];
		a[i] -= temp;
		if (a[i] > 0) {
			add += a[i];
		} else {
			sub -= a[i];
		}
		temp += a[i];
	}
	for (int i = 0; i < q; i++) {
		cin >> l >> r >> d;
		f(l, d);
		f(r+1, -d);
		cout << -(add*s-sub*t) << endl;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...