답안 #971710

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971710 2024-04-29T08:03:55 Z LucaIlie Cigle (COI21_cigle) C++17
100 / 100
115 ms 67664 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 5000;
int d[MAX_N + 1], sd[MAX_N + 1], dp[MAX_N + 1][MAX_N + 1];

int main() {
    int n;

    cin >> n;
    for ( int i = 1; i <= n; i++ ) {
        cin >> d[i];
        sd[i] = sd[i - 1] + d[i];
    }

    for ( int i = 1; i <= n; i++ ) {
        int k = i, c = 0;
        for ( int j = i + 1; j <= n; j++ ) {
            while ( k > 0 && sd[i] - sd[k] < sd[j] - sd[i] )
                k--;

            //printf( "%d %d %d %d\n", k, i, j, sd[j] - sd[i] );
            if ( sd[i] - sd[k] == sd[j] - sd[i] )
                c++;
            if ( k > 0 )
                dp[i][j + 1] = max( dp[i][j + 1], dp[k - 1][i] + c );

        }
        for ( int j = i; j <= n; j++ )
            dp[i][j] = max( dp[i][j], max( dp[i - 1][j], dp[i][j - 1] ) );
    }

    /*for ( int i = 1; i <= n; i++ ) {
        for ( int j = 1; j <= n; j++ )
            printf( "%d ", dp[i][j] );
        printf( "\n" );
    }*/

    int ans = 0;
    for ( int i = 0; i <= n; i++ )
        ans = max( ans, dp[i][n] );

    cout << ans;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 416 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 440 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 416 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 440 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 0 ms 696 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 760 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 0 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2904 KB Output is correct
2 Correct 2 ms 2852 KB Output is correct
3 Correct 2 ms 2908 KB Output is correct
4 Correct 2 ms 2908 KB Output is correct
5 Correct 2 ms 2908 KB Output is correct
6 Correct 2 ms 2908 KB Output is correct
7 Correct 2 ms 2908 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
9 Correct 3 ms 2908 KB Output is correct
10 Correct 2 ms 2964 KB Output is correct
11 Correct 2 ms 2908 KB Output is correct
12 Correct 2 ms 2728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 416 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 440 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 0 ms 696 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 760 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 0 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 3 ms 2904 KB Output is correct
22 Correct 2 ms 2852 KB Output is correct
23 Correct 2 ms 2908 KB Output is correct
24 Correct 2 ms 2908 KB Output is correct
25 Correct 2 ms 2908 KB Output is correct
26 Correct 2 ms 2908 KB Output is correct
27 Correct 2 ms 2908 KB Output is correct
28 Correct 2 ms 2908 KB Output is correct
29 Correct 3 ms 2908 KB Output is correct
30 Correct 2 ms 2964 KB Output is correct
31 Correct 2 ms 2908 KB Output is correct
32 Correct 2 ms 2728 KB Output is correct
33 Correct 2 ms 2908 KB Output is correct
34 Correct 2 ms 2908 KB Output is correct
35 Correct 2 ms 2908 KB Output is correct
36 Correct 2 ms 2952 KB Output is correct
37 Correct 2 ms 2924 KB Output is correct
38 Correct 2 ms 2908 KB Output is correct
39 Correct 2 ms 2908 KB Output is correct
40 Correct 2 ms 2904 KB Output is correct
41 Correct 2 ms 2904 KB Output is correct
42 Correct 2 ms 2904 KB Output is correct
43 Correct 2 ms 2916 KB Output is correct
44 Correct 2 ms 2908 KB Output is correct
45 Correct 2 ms 2904 KB Output is correct
46 Correct 2 ms 2744 KB Output is correct
47 Correct 2 ms 2912 KB Output is correct
48 Correct 2 ms 2916 KB Output is correct
49 Correct 2 ms 2916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 416 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 440 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 0 ms 696 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 760 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 0 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 3 ms 2904 KB Output is correct
22 Correct 2 ms 2852 KB Output is correct
23 Correct 2 ms 2908 KB Output is correct
24 Correct 2 ms 2908 KB Output is correct
25 Correct 2 ms 2908 KB Output is correct
26 Correct 2 ms 2908 KB Output is correct
27 Correct 2 ms 2908 KB Output is correct
28 Correct 2 ms 2908 KB Output is correct
29 Correct 3 ms 2908 KB Output is correct
30 Correct 2 ms 2964 KB Output is correct
31 Correct 2 ms 2908 KB Output is correct
32 Correct 2 ms 2728 KB Output is correct
33 Correct 2 ms 2908 KB Output is correct
34 Correct 2 ms 2908 KB Output is correct
35 Correct 2 ms 2908 KB Output is correct
36 Correct 2 ms 2952 KB Output is correct
37 Correct 2 ms 2924 KB Output is correct
38 Correct 2 ms 2908 KB Output is correct
39 Correct 2 ms 2908 KB Output is correct
40 Correct 2 ms 2904 KB Output is correct
41 Correct 2 ms 2904 KB Output is correct
42 Correct 2 ms 2904 KB Output is correct
43 Correct 2 ms 2916 KB Output is correct
44 Correct 2 ms 2908 KB Output is correct
45 Correct 2 ms 2904 KB Output is correct
46 Correct 2 ms 2744 KB Output is correct
47 Correct 2 ms 2912 KB Output is correct
48 Correct 2 ms 2916 KB Output is correct
49 Correct 2 ms 2916 KB Output is correct
50 Correct 100 ms 67444 KB Output is correct
51 Correct 96 ms 67416 KB Output is correct
52 Correct 97 ms 67396 KB Output is correct
53 Correct 98 ms 67296 KB Output is correct
54 Correct 95 ms 67412 KB Output is correct
55 Correct 93 ms 67216 KB Output is correct
56 Correct 115 ms 67204 KB Output is correct
57 Correct 110 ms 67460 KB Output is correct
58 Correct 111 ms 67412 KB Output is correct
59 Correct 112 ms 67428 KB Output is correct
60 Correct 108 ms 67300 KB Output is correct
61 Correct 109 ms 67664 KB Output is correct
62 Correct 109 ms 67368 KB Output is correct
63 Correct 97 ms 67296 KB Output is correct
64 Correct 105 ms 67356 KB Output is correct
65 Correct 103 ms 67468 KB Output is correct
66 Correct 98 ms 67364 KB Output is correct
67 Correct 94 ms 67324 KB Output is correct
68 Correct 90 ms 67216 KB Output is correct
69 Correct 92 ms 67408 KB Output is correct
70 Correct 105 ms 67412 KB Output is correct
71 Correct 110 ms 67408 KB Output is correct
72 Correct 102 ms 67408 KB Output is correct