Submission #751096

#TimeUsernameProblemLanguageResultExecution timeMemory
751096vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
19 ms1796 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,q,s,t,ans,l,r,h;
ll a[200200],b[200200];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> q >> s >> t;
	for(int i=0; i<=n; i++) {
		cin >> a[i];
	}
	if(q <= 2000 && n <= 2000) {
		for(int i=1; i<=q; i++) {
			cin >> l >> r >> h;
			for(int j=l; j<=r; j++) {	
				a[j] += h;
			}
			ans = 0;
			for(int j=1; j<=n; j++) {
				if(a[j] > a[j-1]) {
					ans -= s*(a[j] - a[j-1]);
				}
				else {
					ans += t*(a[j-1] - a[j]);
				}
			}
			cout << ans << endl;
		}
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...