제출 #129281

#제출 시각아이디문제언어결과실행 시간메모리
129281hungcungFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
204 ms6464 KiB
#include<bits/stdc++.h> using namespace std; int n,q,s,t,l,r,x,a[200005]; long long b[200005]; int main(){ scanf("%d %d %d %d",&n,&q,&s,&t); for(int i=0;i<=n;i++){ scanf("%d",&a[i]); } long long ans=0; for(int i=1;i<=n;i++){ b[i]=a[i-1]-a[i]; if(b[i]<0) ans+=s*b[i]; else ans+=t*b[i]; } while(q--){ scanf("%d %d %d",&l,&r,&x); if(b[l]<0) ans-=s*b[l]; else ans-=t*b[l]; b[l]-=x; if(b[l]<0) ans+=s*b[l]; else ans+=t*b[l]; if(r<n){ if(b[r+1]<0) ans-=s*b[r+1]; else ans-=t*b[r+1]; b[r+1]+=x; if(b[r+1]<0) ans+=s*b[r+1]; else ans+=t*b[r+1]; } printf("%lld\n",ans); } }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d %d",&n,&q,&s,&t);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
foehn_phenomena.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&l,&r,&x);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...