Submission #20915

#TimeUsernameProblemLanguageResultExecution timeMemory
20915gs14004Foehn Phenomena (JOI17_foehn_phenomena)C++11
100 / 100
209 ms3580 KiB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
typedef long long lint;

int n, q, s, t;
lint a[200005], ans;

void upd(int x, int v){
	if(a[x] < 0) ans -= a[x] * t;
	else ans -= a[x] * s;
	a[x] += v;
	if(a[x] < 0) ans += a[x] * t;
	else ans += a[x] * s;
}

int main(){
	scanf("%d %d %d %d %*d",&n,&q,&s,&t);
	int prv = 0;
	for(int i=1; i<=n; i++){
		int x;
		scanf("%d",&x);
		upd(i, x - prv);
		prv = x;
	}
	while(q--){
		int s, e, x;
		scanf("%d %d %d",&s,&e,&x);
		upd(s, x);
		if(e < n) upd(e+1, -x);
		printf("%lld\n", -ans);
	}
}

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:18:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d %d %*d",&n,&q,&s,&t);
                                      ^
foehn_phenomena.cpp:22:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&x);
                 ^
foehn_phenomena.cpp:28:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&s,&e,&x);
                             ^

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...