제출 #33250

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

컴파일 시 표준 에러 (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("%lld %lld %lld %lld",&n,&q,&s,&t);
                                          ^
foehn_phenomena.cpp:8:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<=n;i++) scanf("%lld",&a[i]);
                                           ^
foehn_phenomena.cpp:16:29: 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...