이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.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];
int n, i, j, k, l, x, 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 (i = 0; i <= n; i++)
for (j = i + 1; j <= n; j++)
for (k = j + 1, l = j - 1, x = dp[i][j]; k <= n; k++) {
dp[j][k] = max(dp[j][k], x);
while (l >= 0 && aa[k] + aa[l] > aa[j] * 2)
l--;
if (l > i && aa[k] + aa[l] == aa[j] * 2)
x++;
}
ans = 0;
for (i = 0; i < n; i++)
ans = max(ans, dp[i][n]);
printf("%d\n", ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
cigle.c: In function 'main':
cigle.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
cigle.c:13:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d", &aa[i]);
| ^~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |