제출 #377701

#제출 시각아이디문제언어결과실행 시간메모리
377701rainboyBali Sculptures (APIO15_sculpture)C11
100 / 100
89 ms748 KiB
#include <stdio.h> #include <string.h> #define N 2000 #define H 40 #define INF 0x3f3f3f3f int min(int a, int b) { return a < b ? a : b; } int solve(int *aa, int n, int l, int r, long long x) { static int dp[N + 1], dq[N + 1][N + 1]; int i, j, k; long long sum; if (l == 1) { memset(dp, 0x3f, (n + 1) * sizeof *dp); dp[0] = 0; for (i = 0; i < n; i++) if (dp[i] != INF) { sum = 0; for (j = i + 1; j <= n; j++) { sum += aa[j - 1]; if ((x | sum) == x) dp[j] = min(dp[j], dp[i] + 1); } } return dp[n] <= r; } else { for (i = 0; i <= n; i++) memset(dq[i], 0, (n + 1) * sizeof *dq[i]); dq[0][0] = 1; for (i = 0; i < n; i++) for (k = 0; k < n; k++) if (dq[i][k]) { sum = 0; for (j = i + 1; j <= n; j++) { sum += aa[j - 1]; if ((x | sum) == x) dq[j][k + 1] = 1; } } for (k = l; k <= r; k++) if (dq[n][k]) return 1; return 0; } } int main() { static int aa[N]; int n, l, r, h, i; long long ans; scanf("%d%d%d", &n, &l, &r); for (i = 0; i < n; i++) scanf("%d", &aa[i]); ans = (1LL << H + 1) - 1; for (h = H; h >= 0; h--) if (solve(aa, n, l, r, ans ^ 1LL << h)) ans ^= 1LL << h; printf("%lld\n", ans); return 0; }

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

sculpture.c: In function 'main':
sculpture.c:57:13: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   57 |  ans = (1LL << H + 1) - 1;
      |             ^~
sculpture.c:54:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   54 |  scanf("%d%d%d", &n, &l, &r);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.c:56:3: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   56 |   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...
#Verdict Execution timeMemoryGrader output
Fetching results...