제출 #795745

#제출 시각아이디문제언어결과실행 시간메모리
795745AcanikolicFoehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
1074 ms3528 KiB
#include <bits/stdc++.h>
		 
#define ll long long 
		
#define int long long 
		 
#define pb push_back 
		
#define F first
		 
#define S second
		 
using namespace std;
		 
const long long N = 3e5+10;
		 
const long long mod = 1e9+7;
		 
const long long inf = 1e18;
				
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	
	int n,Q,s,t;
	cin >> n >> Q >> s >> t;
	vector<int>a(n+1);
	for(int i=0;i<=n;i++) cin >> a[i];
	while(Q--) {
		int l,r,x;
		cin >> l >> r >> x;
		for(int i=l;i<=r;i++) a[i] += x;
		int res = 0;
		for(int i=1;i<=n;i++) {
			if(a[i-1] < a[i]) res -= (a[i]-a[i-1])*s;
			else res += (a[i-1]-a[i])*t;
		}
		cout << res << '\n';
	}
    return 0; 
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...