Submission #51499

#TimeUsernameProblemLanguageResultExecution timeMemory
51499vovinamFoehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
86 ms6828 KiB
#include<bits/stdc++.h>
using namespace std;
long long res,a[200005],b[200005],s,t;
long long trans(long long a){
	if(a<0){
		return a*s;
	}
	return a*t;
}
int main(){
	int n,q;
	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+=trans(b[i]);
	}
	for(int i=1;i<=q;i++){
		long long l,r,x;
		scanf("%I64d%I64d%I64d",&l,&r,&x);
		if(l>0){
			res-=trans(b[l]);
			b[l]-=x;
			res+=trans(b[l]);
		}
		if(r<n){
			res-=trans(b[r+1]);
			b[r+1]+=x;
			res+=trans(b[r+1]);
		}
		printf("%I64d\n",res);
	}
}

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:22:35: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   scanf("%I64d%I64d%I64d",&l,&r,&x);
                           ~~      ^
foehn_phenomena.cpp:22:35: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
foehn_phenomena.cpp:22:35: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
foehn_phenomena.cpp:33:23: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   printf("%I64d\n",res);
                       ^
foehn_phenomena.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%I64d%I64d%I64d",&l,&r,&x);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...