Submission #420845

# Submission time Handle Problem Language Result Execution time Memory
420845 2021-06-08T14:21:30 Z HappyPacMan Cigle (COI21_cigle) C++14
100 / 100
315 ms 67504 KB
#include <bits/stdc++.h>
using namespace std;
const int MXN = 5005;
int dp[MXN][MXN];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;
    int arr[N];
    for(int i=0;i<N;i++) cin >> arr[i];
    int res = 0;
    for(int i=1;i<N;i++){
        int pref[i];
        pref[0] = dp[0][i-1];
        for(int j=1;j<i;j++) pref[j] = max(pref[j-1],dp[j][i-1]);
        int l=0,r=0,lst=i-1,cost=0;
        for(int j=i,k=i-1;j<N;j++){
            dp[i][j] = pref[lst] + cost;
            l += arr[j];
            while(k >= 0 && r+arr[k] <= l) r += arr[k--];
            if(l == r && k >= 0){
                cost++,lst=k;
                r += arr[k--];
            }
        }
        for(int j=i+1;j<N;j++) dp[i][j] = max(dp[i][j-1],dp[i][j]);
        for(int j=0;j<N;j++) res = max(res,dp[i][j]);
    }
    cout << res << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2764 KB Output is correct
2 Correct 3 ms 2764 KB Output is correct
3 Correct 3 ms 2764 KB Output is correct
4 Correct 3 ms 2764 KB Output is correct
5 Correct 3 ms 2764 KB Output is correct
6 Correct 3 ms 2764 KB Output is correct
7 Correct 3 ms 2764 KB Output is correct
8 Correct 4 ms 2764 KB Output is correct
9 Correct 3 ms 2764 KB Output is correct
10 Correct 4 ms 2764 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 3 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
21 Correct 4 ms 2764 KB Output is correct
22 Correct 3 ms 2764 KB Output is correct
23 Correct 3 ms 2764 KB Output is correct
24 Correct 3 ms 2764 KB Output is correct
25 Correct 3 ms 2764 KB Output is correct
26 Correct 3 ms 2764 KB Output is correct
27 Correct 3 ms 2764 KB Output is correct
28 Correct 4 ms 2764 KB Output is correct
29 Correct 3 ms 2764 KB Output is correct
30 Correct 4 ms 2764 KB Output is correct
31 Correct 3 ms 2764 KB Output is correct
32 Correct 3 ms 2764 KB Output is correct
33 Correct 3 ms 2764 KB Output is correct
34 Correct 3 ms 2764 KB Output is correct
35 Correct 3 ms 2764 KB Output is correct
36 Correct 3 ms 2764 KB Output is correct
37 Correct 3 ms 2764 KB Output is correct
38 Correct 3 ms 2764 KB Output is correct
39 Correct 4 ms 2764 KB Output is correct
40 Correct 3 ms 2764 KB Output is correct
41 Correct 3 ms 2764 KB Output is correct
42 Correct 3 ms 2764 KB Output is correct
43 Correct 3 ms 2764 KB Output is correct
44 Correct 3 ms 2764 KB Output is correct
45 Correct 3 ms 2764 KB Output is correct
46 Correct 3 ms 2764 KB Output is correct
47 Correct 3 ms 2764 KB Output is correct
48 Correct 4 ms 2764 KB Output is correct
49 Correct 3 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
21 Correct 4 ms 2764 KB Output is correct
22 Correct 3 ms 2764 KB Output is correct
23 Correct 3 ms 2764 KB Output is correct
24 Correct 3 ms 2764 KB Output is correct
25 Correct 3 ms 2764 KB Output is correct
26 Correct 3 ms 2764 KB Output is correct
27 Correct 3 ms 2764 KB Output is correct
28 Correct 4 ms 2764 KB Output is correct
29 Correct 3 ms 2764 KB Output is correct
30 Correct 4 ms 2764 KB Output is correct
31 Correct 3 ms 2764 KB Output is correct
32 Correct 3 ms 2764 KB Output is correct
33 Correct 3 ms 2764 KB Output is correct
34 Correct 3 ms 2764 KB Output is correct
35 Correct 3 ms 2764 KB Output is correct
36 Correct 3 ms 2764 KB Output is correct
37 Correct 3 ms 2764 KB Output is correct
38 Correct 3 ms 2764 KB Output is correct
39 Correct 4 ms 2764 KB Output is correct
40 Correct 3 ms 2764 KB Output is correct
41 Correct 3 ms 2764 KB Output is correct
42 Correct 3 ms 2764 KB Output is correct
43 Correct 3 ms 2764 KB Output is correct
44 Correct 3 ms 2764 KB Output is correct
45 Correct 3 ms 2764 KB Output is correct
46 Correct 3 ms 2764 KB Output is correct
47 Correct 3 ms 2764 KB Output is correct
48 Correct 4 ms 2764 KB Output is correct
49 Correct 3 ms 2764 KB Output is correct
50 Correct 259 ms 67276 KB Output is correct
51 Correct 260 ms 67312 KB Output is correct
52 Correct 249 ms 67292 KB Output is correct
53 Correct 254 ms 67284 KB Output is correct
54 Correct 247 ms 67220 KB Output is correct
55 Correct 247 ms 67188 KB Output is correct
56 Correct 290 ms 67268 KB Output is correct
57 Correct 284 ms 67304 KB Output is correct
58 Correct 294 ms 67504 KB Output is correct
59 Correct 299 ms 67300 KB Output is correct
60 Correct 296 ms 67220 KB Output is correct
61 Correct 275 ms 67188 KB Output is correct
62 Correct 281 ms 67268 KB Output is correct
63 Correct 258 ms 67260 KB Output is correct
64 Correct 266 ms 67196 KB Output is correct
65 Correct 269 ms 67180 KB Output is correct
66 Correct 300 ms 67240 KB Output is correct
67 Correct 262 ms 67276 KB Output is correct
68 Correct 281 ms 67264 KB Output is correct
69 Correct 253 ms 67248 KB Output is correct
70 Correct 315 ms 67284 KB Output is correct
71 Correct 291 ms 67268 KB Output is correct
72 Correct 312 ms 67248 KB Output is correct