제출 #33276

#제출 시각아이디문제언어결과실행 시간메모리
33276Dat160601Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
219 ms5140 KiB
#include <bits/stdc++.h> using namespace std; const int N=200007; int n,q,l,r; long long a[N],v,up,down,ans=0,dif[N]; int main(){ scanf("%d %d %lld %lld",&n,&q,&up,&down); scanf("%lld",&a[0]); for(int i=1;i<=n;i++) scanf("%lld",&a[i]); for(int i=0;i<n;i++){ if(a[i]<a[i+1]) ans-=up*abs(a[i]-a[i+1]); else ans+=down*abs(a[i]-a[i+1]); } for(int i=0;i<n;i++){ dif[i]=a[i]-a[i+1]; } while(q--){ scanf("%d %d %lld",&l,&r,&v); long long old=dif[l-1]; dif[l-1]-=v; if(old<0) ans+=up*(-old); else ans-=down*old; if(dif[l-1]<0) ans-=up*(-dif[l-1]); else ans+=down*dif[l-1]; if(r<n){ old=dif[r]; dif[r]+=v; if(old<0) ans+=up*(-old); else ans-=down*old; if(dif[r]<0) ans-=up*(-dif[r]); else ans+=down*dif[r]; } printf("%lld\n",ans); } }

컴파일 시 표준 에러 (stderr) 메시지

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:7:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %lld %lld",&n,&q,&up,&down);
                                          ^
foehn_phenomena.cpp:8:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&a[0]);
                     ^
foehn_phenomena.cpp:9:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
                                           ^
foehn_phenomena.cpp:18:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %lld",&l,&r,&v);
                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...