제출 #134518

#제출 시각아이디문제언어결과실행 시간메모리
134518junodeveloperFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
186 ms13304 KiB
#include <bits/stdc++.h> #define sz(x) ((int)x.size()) #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef long double ld; int n, Q; ll S, T, a[200010], b[200010]; int main() { scanf("%d%d%lld%lld",&n,&Q,&S,&T); int i; ll sum = 0; for(i=0;i<=n;i++) { scanf("%lld",a+i); if(i) { b[i]=a[i]-a[i-1]; if(b[i]>0) sum-=S*b[i]; else sum-=T*b[i]; } } while(Q--) { int l, r; ll x; scanf("%d%d%lld",&l,&r,&x); if(b[l]>0) sum+=S*b[l]; else sum+=T*b[l]; if(b[r+1]>0) sum+=S*b[r+1]; else sum+=T*b[r+1]; b[l]+=x; if(r+1<=n)b[r+1]-=x; if(b[l]>0) sum-=S*b[l]; else sum-=T*b[l]; if(b[r+1]>0) sum-=S*b[r+1]; else sum-=T*b[r+1]; printf("%lld\n",sum); } return 0; }

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

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