Submission #493280

#TimeUsernameProblemLanguageResultExecution timeMemory
493280rainboyCigle (COI21_cigle)C11
100 / 100
263 ms67404 KiB
#include <stdio.h> #include <string.h> #define N 5000 int max(int a, int b) { return a > b ? a : b; } int main() { static int aa[N + 1], dp[N + 1][N + 1], dq[N + 1]; int n, i, j, k, x, c, ans; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &aa[i]); aa[i] += aa[i - 1]; } for (i = 1; i <= n; i++) dp[0][i] = 0; for (j = 1; j <= n; j++) { for (i = 0; i < j; i++) dq[i] = dp[i][j]; for (i = 1; i < j; i++) dq[i] = max(dq[i], dq[i - 1]); x = 0, c = 0; for (i = j - 1, k = j + 1; k <= n; k++) { dp[j][k] = x; while (i >= 0 && aa[i] + aa[k] > aa[j] * 2) i--; if (i > 0 && aa[i] + aa[k] == aa[j] * 2) x = max(x, dq[i - 1] + ++c); } } ans = 0; for (i = 0; i < n; i++) ans = max(ans, dp[i][n]); printf("%d\n", ans); return 0; }

Compilation message (stderr)

cigle.c: In function 'main':
cigle.c:12:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
cigle.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   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...