답안 #1033491

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1033491 2024-07-24T22:50:45 Z tvladm2009 Cigle (COI21_cigle) C++17
48 / 100
1000 ms 9828 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define x first
#define y second
#define sz(a) a.size()

typedef long long ll;

const int N = 5e3 + 7;

int a[N];
int dp[N][N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            int cnt = 0;
            int cur = i;
            int sa = 0;
            int sb = 0;
            for (int k = i - 1; k >= 0; k--) {
                sa += a[k];
                while (cur <= j && sb < sa) {
                    sb += a[cur];
                    cur++;
                }
                dp[i][j] = max(dp[i][j], dp[k][i - 1] + cnt);
                if (sa == sb && cur <= j) 
                    cnt++;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) 
        ans = max(ans, dp[i][n - 1]);
    cout << ans << "\n";
    return 0;
}
 

# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 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 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 2896 KB Output is correct
2 Correct 39 ms 2684 KB Output is correct
3 Correct 45 ms 2896 KB Output is correct
4 Correct 40 ms 2900 KB Output is correct
5 Correct 40 ms 2712 KB Output is correct
6 Correct 49 ms 2896 KB Output is correct
7 Correct 41 ms 2880 KB Output is correct
8 Correct 39 ms 2832 KB Output is correct
9 Correct 39 ms 2796 KB Output is correct
10 Correct 43 ms 2900 KB Output is correct
11 Correct 42 ms 2900 KB Output is correct
12 Correct 38 ms 2896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 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 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 38 ms 2896 KB Output is correct
22 Correct 39 ms 2684 KB Output is correct
23 Correct 45 ms 2896 KB Output is correct
24 Correct 40 ms 2900 KB Output is correct
25 Correct 40 ms 2712 KB Output is correct
26 Correct 49 ms 2896 KB Output is correct
27 Correct 41 ms 2880 KB Output is correct
28 Correct 39 ms 2832 KB Output is correct
29 Correct 39 ms 2796 KB Output is correct
30 Correct 43 ms 2900 KB Output is correct
31 Correct 42 ms 2900 KB Output is correct
32 Correct 38 ms 2896 KB Output is correct
33 Correct 41 ms 2900 KB Output is correct
34 Correct 40 ms 2896 KB Output is correct
35 Correct 41 ms 2900 KB Output is correct
36 Correct 45 ms 3152 KB Output is correct
37 Correct 39 ms 2900 KB Output is correct
38 Correct 43 ms 2908 KB Output is correct
39 Correct 37 ms 2900 KB Output is correct
40 Correct 37 ms 2844 KB Output is correct
41 Correct 46 ms 2868 KB Output is correct
42 Correct 47 ms 2896 KB Output is correct
43 Correct 41 ms 2900 KB Output is correct
44 Correct 40 ms 2900 KB Output is correct
45 Correct 47 ms 2900 KB Output is correct
46 Correct 35 ms 2860 KB Output is correct
47 Correct 36 ms 2896 KB Output is correct
48 Correct 35 ms 2896 KB Output is correct
49 Correct 46 ms 2896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 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 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 38 ms 2896 KB Output is correct
22 Correct 39 ms 2684 KB Output is correct
23 Correct 45 ms 2896 KB Output is correct
24 Correct 40 ms 2900 KB Output is correct
25 Correct 40 ms 2712 KB Output is correct
26 Correct 49 ms 2896 KB Output is correct
27 Correct 41 ms 2880 KB Output is correct
28 Correct 39 ms 2832 KB Output is correct
29 Correct 39 ms 2796 KB Output is correct
30 Correct 43 ms 2900 KB Output is correct
31 Correct 42 ms 2900 KB Output is correct
32 Correct 38 ms 2896 KB Output is correct
33 Correct 41 ms 2900 KB Output is correct
34 Correct 40 ms 2896 KB Output is correct
35 Correct 41 ms 2900 KB Output is correct
36 Correct 45 ms 3152 KB Output is correct
37 Correct 39 ms 2900 KB Output is correct
38 Correct 43 ms 2908 KB Output is correct
39 Correct 37 ms 2900 KB Output is correct
40 Correct 37 ms 2844 KB Output is correct
41 Correct 46 ms 2868 KB Output is correct
42 Correct 47 ms 2896 KB Output is correct
43 Correct 41 ms 2900 KB Output is correct
44 Correct 40 ms 2900 KB Output is correct
45 Correct 47 ms 2900 KB Output is correct
46 Correct 35 ms 2860 KB Output is correct
47 Correct 36 ms 2896 KB Output is correct
48 Correct 35 ms 2896 KB Output is correct
49 Correct 46 ms 2896 KB Output is correct
50 Execution timed out 1071 ms 9828 KB Time limit exceeded
51 Halted 0 ms 0 KB -