제출 #544722

#제출 시각아이디문제언어결과실행 시간메모리
544722rainboyHacker (BOI15_hac)C11
100 / 100
75 ms7224 KiB
#include <stdio.h> #define N 500000 int max(int a, int b) { return a > b ? a : b; } int main() { static int aa[N], ss[N], qu[N * 2]; int n, k, i, head, cnt, ans; scanf("%d", &n), k = (n + 1) / 2; for (i = 0; i < n; i++) { scanf("%d", &aa[i]); if (i * 2 < n) ss[0] += aa[i]; } for (i = 1; i < n; i++) ss[i] = ss[i - 1] - aa[i - 1] + aa[(i + k - 1) % n]; head = cnt = 0, ans = 0; for (i = 0; i < n + k; i++) { while (cnt && ss[qu[head + cnt - 1] % n] >= ss[i % n]) cnt--; qu[head + cnt++] = i; if (i >= k - 1) { ans = max(ans, ss[qu[head] % n]); if (qu[head] == i - k + 1) head++, cnt--; } } printf("%d\n", ans); return 0; }

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

hac.c: In function 'main':
hac.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &n), k = (n + 1) / 2;
      |  ^~~~~~~~~~~~~~~
hac.c:13:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...