답안 #693847

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
693847 2023-02-03T10:17:29 Z 79brue Cigle (COI21_cigle) C++17
48 / 100
1000 ms 11124 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
int arr[5002];
int DP[5002][5002];
int ans;

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++) scanf("%d", &arr[i]);
    for(int m=1; m<n; m++){
        for(int s=1; s<=m; s++){
            int tmp = m, off = arr[m], ret = DP[s][m];
            bool ended = 0;
            for(int e=m+1; e<n; e++){
                int v = arr[e];
                while(!ended && off < v){
                    v -= off;
                    off = arr[--tmp];
                    if(tmp <= s){
                        ended = 1;
                        break;
                    }
                }
                if(!ended){
                    if(off == v) ret++, off = 0;
                    else off -= v;
                }
                DP[m+1][e+1] = max(DP[m+1][e+1], ret);
            }
        }
    }
//    for(int i=1; i<=n; i++) for(int j=i; j<=n; j++) printf("%d %d: %d\n", i, j, DP[i][j]);
    for(int i=1; i<n; i++) ans = max(ans, DP[i][n]);
    printf("%d", ans);
}

Compilation message

cigle.cpp: In function 'int main()':
cigle.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
cigle.cpp:14:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     for(int i=1; i<=n; i++) scanf("%d", &arr[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 2764 KB Output is correct
2 Correct 52 ms 2776 KB Output is correct
3 Correct 53 ms 2756 KB Output is correct
4 Correct 62 ms 2728 KB Output is correct
5 Correct 58 ms 2700 KB Output is correct
6 Correct 70 ms 2724 KB Output is correct
7 Correct 70 ms 2740 KB Output is correct
8 Correct 86 ms 2832 KB Output is correct
9 Correct 70 ms 2764 KB Output is correct
10 Correct 62 ms 2712 KB Output is correct
11 Correct 67 ms 2764 KB Output is correct
12 Correct 63 ms 2708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 61 ms 2764 KB Output is correct
22 Correct 52 ms 2776 KB Output is correct
23 Correct 53 ms 2756 KB Output is correct
24 Correct 62 ms 2728 KB Output is correct
25 Correct 58 ms 2700 KB Output is correct
26 Correct 70 ms 2724 KB Output is correct
27 Correct 70 ms 2740 KB Output is correct
28 Correct 86 ms 2832 KB Output is correct
29 Correct 70 ms 2764 KB Output is correct
30 Correct 62 ms 2712 KB Output is correct
31 Correct 67 ms 2764 KB Output is correct
32 Correct 63 ms 2708 KB Output is correct
33 Correct 54 ms 2764 KB Output is correct
34 Correct 55 ms 2776 KB Output is correct
35 Correct 57 ms 2796 KB Output is correct
36 Correct 55 ms 2700 KB Output is correct
37 Correct 71 ms 2764 KB Output is correct
38 Correct 72 ms 2688 KB Output is correct
39 Correct 81 ms 2716 KB Output is correct
40 Correct 83 ms 3036 KB Output is correct
41 Correct 69 ms 2772 KB Output is correct
42 Correct 73 ms 2768 KB Output is correct
43 Correct 68 ms 2696 KB Output is correct
44 Correct 84 ms 2692 KB Output is correct
45 Correct 81 ms 2724 KB Output is correct
46 Correct 71 ms 2760 KB Output is correct
47 Correct 77 ms 2716 KB Output is correct
48 Correct 65 ms 2684 KB Output is correct
49 Correct 67 ms 2760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 61 ms 2764 KB Output is correct
22 Correct 52 ms 2776 KB Output is correct
23 Correct 53 ms 2756 KB Output is correct
24 Correct 62 ms 2728 KB Output is correct
25 Correct 58 ms 2700 KB Output is correct
26 Correct 70 ms 2724 KB Output is correct
27 Correct 70 ms 2740 KB Output is correct
28 Correct 86 ms 2832 KB Output is correct
29 Correct 70 ms 2764 KB Output is correct
30 Correct 62 ms 2712 KB Output is correct
31 Correct 67 ms 2764 KB Output is correct
32 Correct 63 ms 2708 KB Output is correct
33 Correct 54 ms 2764 KB Output is correct
34 Correct 55 ms 2776 KB Output is correct
35 Correct 57 ms 2796 KB Output is correct
36 Correct 55 ms 2700 KB Output is correct
37 Correct 71 ms 2764 KB Output is correct
38 Correct 72 ms 2688 KB Output is correct
39 Correct 81 ms 2716 KB Output is correct
40 Correct 83 ms 3036 KB Output is correct
41 Correct 69 ms 2772 KB Output is correct
42 Correct 73 ms 2768 KB Output is correct
43 Correct 68 ms 2696 KB Output is correct
44 Correct 84 ms 2692 KB Output is correct
45 Correct 81 ms 2724 KB Output is correct
46 Correct 71 ms 2760 KB Output is correct
47 Correct 77 ms 2716 KB Output is correct
48 Correct 65 ms 2684 KB Output is correct
49 Correct 67 ms 2760 KB Output is correct
50 Execution timed out 1083 ms 11124 KB Time limit exceeded
51 Halted 0 ms 0 KB -