제출 #20966

#제출 시각아이디문제언어결과실행 시간메모리
20966kdh9949Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
229 ms3580 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, q; ll S, T, a[200010], ans; ll f(int x){ return a[x] > 0 ? -S * a[x] : -T * a[x]; } void upd(int x, ll v){ ans -= f(x); a[x] += v; ans += f(x); } int main(){ scanf("%d%d%lld%lld", &n, &q, &S, &T); for(int i = 0; i <= n; i++) scanf("%lld", a + i); for(int i = n; i >= 1; i--) a[i] -= a[i - 1]; for(int i = 1; i <= n; i++) ans += f(i); for(int i = 0; i < q; i++){ int s, e; ll x; scanf("%d%d%lld", &s, &e, &x); upd(s, x); if(e < n) upd(e + 1, -x); printf("%lld\n", ans); } }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:17:39: 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:18:50: 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:22:48: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int s, e; ll x; scanf("%d%d%lld", &s, &e, &x);
                                                ^

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...