제출 #705287

#제출 시각아이디문제언어결과실행 시간메모리
705287rainboyFoehn Phenomena (JOI17_foehn_phenomena)C11
100 / 100
140 ms11492 KiB
#include <stdio.h> #define N 200000 int main() { static long long aa[N + 1]; int n, q, s, t, i; long long ans; scanf("%d%d%d%d", &n, &q, &s, &t); for (i = 0; i <= n; i++) scanf("%lld", &aa[i]); for (i = n; i > 0; i--) aa[i] -= aa[i - 1]; ans = 0; for (i = 1; i <= n; i++) ans -= aa[i] > 0 ? s * aa[i] : t * aa[i]; while (q--) { int l, r, x; scanf("%d%d%d", &l, &r, &x); ans += aa[l] > 0 ? s * aa[l] : t * aa[l]; aa[l] += x; ans -= aa[l] > 0 ? s * aa[l] : t * aa[l]; if (r < n) { ans += aa[r + 1] > 0 ? s * aa[r + 1] : t * aa[r + 1]; aa[r + 1] -= x; ans -= aa[r + 1] > 0 ? s * aa[r + 1] : t * aa[r + 1]; } printf("%lld\n", ans); } return 0; }

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

foehn_phenomena.c: In function 'main':
foehn_phenomena.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d%d%d%d", &n, &q, &s, &t);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.c:12:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%lld", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.c:21:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   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...