제출 #51457

#제출 시각아이디문제언어결과실행 시간메모리
51457IOrtroiiiFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
522 ms7548 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 5;

int n, q;
long long s, t;
long long a[N], b[N];
long long res = 0;

long long fuck(long long x) {
	if (x < 0) return s * x;
	return t * x;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> q >> s >> t;
	for (int i = 0;i <= n;++i) cin >> a[i];
	for (int i = 1;i <= n;++i) {
		b[i] = a[i - 1] - a[i];
		res += fuck(b[i]);
	}
	while (q--) {
		int l, r; long long x;
		cin >> l >> r >> x;
		if (l) {
			res -= fuck(b[l]);
			b[l] -= x;
			res += fuck(b[l]);
		}
		if (r < n) {
			res -= fuck(b[r + 1]);
			b[r + 1] += x;
			res += fuck(b[r + 1]);
		}
		cout << res << '\n';
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...