Submission #871388

# Submission time Handle Problem Language Result Execution time Memory
871388 2023-11-10T17:01:37 Z Trisanu_Das Tortoise (CEOI21_tortoise) C++17
48 / 100
281 ms 430928 KB
#include <bits/stdc++.h>
using namespace std;
 
int n, arr[302], sum[302], DP[603][302][302][2], ans;
 
int main(){
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> arr[i];
        sum[i] = sum[i-1];
        if(arr[i] > 0) sum[i] += arr[i];
    }
    for(int i=0; i<=n+n+1; i++) for(int j=0; j<=n; j++) for(int k=0; k<=n; k++) DP[i][j][k][0] = DP[i][j][k][1] = 1e9;
    DP[0][1][0][0] = 0;
    for(int t=0; t<=n+n+1; t++){
        for(int i=1; i<=n; i++){
            for(int j=0; j<=n; j++){
                for(int c=0; c<2; c++) if(DP[t][i][j][c] < 1e9) ans = max(ans, j);
                if(arr[i] == -1) DP[t][i][j][0] = min(DP[t][i][j][0], DP[t][i][j][1]);
                if(arr[i] > 0 && DP[t][i][j][0] < sum[i] && i+i-2 >= t) DP[t][i][j+1][1] = min(DP[t][i][j+1][1], max(DP[t][i][j][0], sum[i-1])+1);
                for(int c=0; c<2; c++){
                    DP[t+1][i-1][j][c] = min(DP[t+1][i-1][j][c], DP[t][i][j][c]);
                    DP[t+1][i+1][j][c] = min(DP[t+1][i+1][j][c], DP[t][i][j][c]);
                }
            }
        }
    }
    cout << sum[n] - ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 24924 KB Output is correct
2 Correct 3 ms 24924 KB Output is correct
3 Correct 3 ms 24924 KB Output is correct
4 Correct 3 ms 25104 KB Output is correct
5 Correct 3 ms 24924 KB Output is correct
6 Correct 3 ms 25024 KB Output is correct
7 Correct 3 ms 24924 KB Output is correct
8 Correct 3 ms 25108 KB Output is correct
9 Correct 3 ms 24920 KB Output is correct
10 Correct 3 ms 25176 KB Output is correct
11 Correct 3 ms 24924 KB Output is correct
12 Correct 3 ms 25076 KB Output is correct
13 Correct 3 ms 24924 KB Output is correct
14 Correct 3 ms 24924 KB Output is correct
15 Correct 3 ms 25016 KB Output is correct
16 Correct 3 ms 24920 KB Output is correct
17 Correct 3 ms 24924 KB Output is correct
18 Correct 3 ms 24924 KB Output is correct
19 Correct 3 ms 24924 KB Output is correct
20 Correct 3 ms 24920 KB Output is correct
21 Correct 3 ms 24924 KB Output is correct
22 Correct 3 ms 24924 KB Output is correct
23 Correct 3 ms 25016 KB Output is correct
24 Correct 3 ms 24924 KB Output is correct
25 Correct 3 ms 24924 KB Output is correct
26 Correct 3 ms 24924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 24924 KB Output is correct
2 Correct 3 ms 24924 KB Output is correct
3 Correct 3 ms 24924 KB Output is correct
4 Correct 3 ms 25104 KB Output is correct
5 Correct 3 ms 24924 KB Output is correct
6 Correct 3 ms 25024 KB Output is correct
7 Correct 3 ms 24924 KB Output is correct
8 Correct 3 ms 25108 KB Output is correct
9 Correct 3 ms 24920 KB Output is correct
10 Correct 3 ms 25176 KB Output is correct
11 Correct 3 ms 24924 KB Output is correct
12 Correct 3 ms 25076 KB Output is correct
13 Correct 3 ms 24924 KB Output is correct
14 Correct 3 ms 24924 KB Output is correct
15 Correct 3 ms 25016 KB Output is correct
16 Correct 3 ms 24920 KB Output is correct
17 Correct 3 ms 24924 KB Output is correct
18 Correct 3 ms 24924 KB Output is correct
19 Correct 3 ms 24924 KB Output is correct
20 Correct 3 ms 24920 KB Output is correct
21 Correct 3 ms 24924 KB Output is correct
22 Correct 3 ms 24924 KB Output is correct
23 Correct 3 ms 25016 KB Output is correct
24 Correct 3 ms 24924 KB Output is correct
25 Correct 3 ms 24924 KB Output is correct
26 Correct 3 ms 24924 KB Output is correct
27 Correct 211 ms 343524 KB Output is correct
28 Correct 258 ms 417372 KB Output is correct
29 Correct 211 ms 394072 KB Output is correct
30 Correct 171 ms 360076 KB Output is correct
31 Correct 249 ms 421072 KB Output is correct
32 Correct 110 ms 310356 KB Output is correct
33 Correct 209 ms 387664 KB Output is correct
34 Correct 171 ms 359324 KB Output is correct
35 Correct 266 ms 430672 KB Output is correct
36 Correct 281 ms 430928 KB Output is correct
37 Correct 264 ms 430676 KB Output is correct
38 Correct 280 ms 430712 KB Output is correct
39 Correct 277 ms 430924 KB Output is correct
40 Correct 264 ms 430708 KB Output is correct
41 Correct 270 ms 430928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 24924 KB Output is correct
2 Correct 3 ms 24924 KB Output is correct
3 Correct 3 ms 24924 KB Output is correct
4 Correct 3 ms 25104 KB Output is correct
5 Correct 3 ms 24924 KB Output is correct
6 Correct 3 ms 25024 KB Output is correct
7 Correct 3 ms 24924 KB Output is correct
8 Correct 3 ms 25108 KB Output is correct
9 Correct 3 ms 24920 KB Output is correct
10 Correct 3 ms 25176 KB Output is correct
11 Correct 3 ms 24924 KB Output is correct
12 Correct 3 ms 25076 KB Output is correct
13 Correct 3 ms 24924 KB Output is correct
14 Correct 3 ms 24924 KB Output is correct
15 Correct 3 ms 25016 KB Output is correct
16 Correct 3 ms 24920 KB Output is correct
17 Correct 3 ms 24924 KB Output is correct
18 Correct 3 ms 24924 KB Output is correct
19 Correct 3 ms 24924 KB Output is correct
20 Correct 3 ms 24920 KB Output is correct
21 Correct 3 ms 24924 KB Output is correct
22 Correct 3 ms 24924 KB Output is correct
23 Correct 3 ms 25016 KB Output is correct
24 Correct 3 ms 24924 KB Output is correct
25 Correct 3 ms 24924 KB Output is correct
26 Correct 3 ms 24924 KB Output is correct
27 Correct 211 ms 343524 KB Output is correct
28 Correct 258 ms 417372 KB Output is correct
29 Correct 211 ms 394072 KB Output is correct
30 Correct 171 ms 360076 KB Output is correct
31 Correct 249 ms 421072 KB Output is correct
32 Correct 110 ms 310356 KB Output is correct
33 Correct 209 ms 387664 KB Output is correct
34 Correct 171 ms 359324 KB Output is correct
35 Correct 266 ms 430672 KB Output is correct
36 Correct 281 ms 430928 KB Output is correct
37 Correct 264 ms 430676 KB Output is correct
38 Correct 280 ms 430712 KB Output is correct
39 Correct 277 ms 430924 KB Output is correct
40 Correct 264 ms 430708 KB Output is correct
41 Correct 270 ms 430928 KB Output is correct
42 Correct 99 ms 291988 KB Output is correct
43 Correct 104 ms 300196 KB Output is correct
44 Correct 143 ms 336720 KB Output is correct
45 Correct 224 ms 399976 KB Output is correct
46 Correct 123 ms 324432 KB Output is correct
47 Correct 99 ms 291920 KB Output is correct
48 Correct 177 ms 365008 KB Output is correct
49 Correct 129 ms 326484 KB Output is correct
50 Correct 209 ms 385812 KB Output is correct
51 Correct 237 ms 407376 KB Output is correct
52 Correct 105 ms 304208 KB Output is correct
53 Correct 224 ms 398672 KB Output is correct
54 Correct 232 ms 396884 KB Output is correct
55 Correct 172 ms 359248 KB Output is correct
56 Correct 251 ms 422520 KB Output is correct
57 Correct 106 ms 300196 KB Output is correct
58 Correct 218 ms 393776 KB Output is correct
59 Correct 121 ms 320336 KB Output is correct
60 Correct 193 ms 367400 KB Output is correct
61 Correct 209 ms 385616 KB Output is correct
62 Correct 207 ms 388852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 24924 KB Output is correct
2 Correct 3 ms 24924 KB Output is correct
3 Correct 3 ms 24924 KB Output is correct
4 Correct 3 ms 25104 KB Output is correct
5 Correct 3 ms 24924 KB Output is correct
6 Correct 3 ms 25024 KB Output is correct
7 Correct 3 ms 24924 KB Output is correct
8 Correct 3 ms 25108 KB Output is correct
9 Correct 3 ms 24920 KB Output is correct
10 Correct 3 ms 25176 KB Output is correct
11 Correct 3 ms 24924 KB Output is correct
12 Correct 3 ms 25076 KB Output is correct
13 Correct 3 ms 24924 KB Output is correct
14 Correct 3 ms 24924 KB Output is correct
15 Correct 3 ms 25016 KB Output is correct
16 Correct 3 ms 24920 KB Output is correct
17 Correct 3 ms 24924 KB Output is correct
18 Correct 3 ms 24924 KB Output is correct
19 Correct 3 ms 24924 KB Output is correct
20 Correct 3 ms 24920 KB Output is correct
21 Correct 3 ms 24924 KB Output is correct
22 Correct 3 ms 24924 KB Output is correct
23 Correct 3 ms 25016 KB Output is correct
24 Correct 3 ms 24924 KB Output is correct
25 Correct 3 ms 24924 KB Output is correct
26 Correct 3 ms 24924 KB Output is correct
27 Correct 211 ms 343524 KB Output is correct
28 Correct 258 ms 417372 KB Output is correct
29 Correct 211 ms 394072 KB Output is correct
30 Correct 171 ms 360076 KB Output is correct
31 Correct 249 ms 421072 KB Output is correct
32 Correct 110 ms 310356 KB Output is correct
33 Correct 209 ms 387664 KB Output is correct
34 Correct 171 ms 359324 KB Output is correct
35 Correct 266 ms 430672 KB Output is correct
36 Correct 281 ms 430928 KB Output is correct
37 Correct 264 ms 430676 KB Output is correct
38 Correct 280 ms 430712 KB Output is correct
39 Correct 277 ms 430924 KB Output is correct
40 Correct 264 ms 430708 KB Output is correct
41 Correct 270 ms 430928 KB Output is correct
42 Correct 99 ms 291988 KB Output is correct
43 Correct 104 ms 300196 KB Output is correct
44 Correct 143 ms 336720 KB Output is correct
45 Correct 224 ms 399976 KB Output is correct
46 Correct 123 ms 324432 KB Output is correct
47 Correct 99 ms 291920 KB Output is correct
48 Correct 177 ms 365008 KB Output is correct
49 Correct 129 ms 326484 KB Output is correct
50 Correct 209 ms 385812 KB Output is correct
51 Correct 237 ms 407376 KB Output is correct
52 Correct 105 ms 304208 KB Output is correct
53 Correct 224 ms 398672 KB Output is correct
54 Correct 232 ms 396884 KB Output is correct
55 Correct 172 ms 359248 KB Output is correct
56 Correct 251 ms 422520 KB Output is correct
57 Correct 106 ms 300196 KB Output is correct
58 Correct 218 ms 393776 KB Output is correct
59 Correct 121 ms 320336 KB Output is correct
60 Correct 193 ms 367400 KB Output is correct
61 Correct 209 ms 385616 KB Output is correct
62 Correct 207 ms 388852 KB Output is correct
63 Incorrect 1 ms 2396 KB Output isn't correct
64 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 24924 KB Output is correct
2 Correct 3 ms 24924 KB Output is correct
3 Correct 3 ms 24924 KB Output is correct
4 Correct 3 ms 25104 KB Output is correct
5 Correct 3 ms 24924 KB Output is correct
6 Correct 3 ms 25024 KB Output is correct
7 Correct 3 ms 24924 KB Output is correct
8 Correct 3 ms 25108 KB Output is correct
9 Correct 3 ms 24920 KB Output is correct
10 Correct 3 ms 25176 KB Output is correct
11 Correct 3 ms 24924 KB Output is correct
12 Correct 3 ms 25076 KB Output is correct
13 Correct 3 ms 24924 KB Output is correct
14 Correct 3 ms 24924 KB Output is correct
15 Correct 3 ms 25016 KB Output is correct
16 Correct 3 ms 24920 KB Output is correct
17 Correct 3 ms 24924 KB Output is correct
18 Correct 3 ms 24924 KB Output is correct
19 Correct 3 ms 24924 KB Output is correct
20 Correct 3 ms 24920 KB Output is correct
21 Correct 3 ms 24924 KB Output is correct
22 Correct 3 ms 24924 KB Output is correct
23 Correct 3 ms 25016 KB Output is correct
24 Correct 3 ms 24924 KB Output is correct
25 Correct 3 ms 24924 KB Output is correct
26 Correct 3 ms 24924 KB Output is correct
27 Correct 211 ms 343524 KB Output is correct
28 Correct 258 ms 417372 KB Output is correct
29 Correct 211 ms 394072 KB Output is correct
30 Correct 171 ms 360076 KB Output is correct
31 Correct 249 ms 421072 KB Output is correct
32 Correct 110 ms 310356 KB Output is correct
33 Correct 209 ms 387664 KB Output is correct
34 Correct 171 ms 359324 KB Output is correct
35 Correct 266 ms 430672 KB Output is correct
36 Correct 281 ms 430928 KB Output is correct
37 Correct 264 ms 430676 KB Output is correct
38 Correct 280 ms 430712 KB Output is correct
39 Correct 277 ms 430924 KB Output is correct
40 Correct 264 ms 430708 KB Output is correct
41 Correct 270 ms 430928 KB Output is correct
42 Correct 99 ms 291988 KB Output is correct
43 Correct 104 ms 300196 KB Output is correct
44 Correct 143 ms 336720 KB Output is correct
45 Correct 224 ms 399976 KB Output is correct
46 Correct 123 ms 324432 KB Output is correct
47 Correct 99 ms 291920 KB Output is correct
48 Correct 177 ms 365008 KB Output is correct
49 Correct 129 ms 326484 KB Output is correct
50 Correct 209 ms 385812 KB Output is correct
51 Correct 237 ms 407376 KB Output is correct
52 Correct 105 ms 304208 KB Output is correct
53 Correct 224 ms 398672 KB Output is correct
54 Correct 232 ms 396884 KB Output is correct
55 Correct 172 ms 359248 KB Output is correct
56 Correct 251 ms 422520 KB Output is correct
57 Correct 106 ms 300196 KB Output is correct
58 Correct 218 ms 393776 KB Output is correct
59 Correct 121 ms 320336 KB Output is correct
60 Correct 193 ms 367400 KB Output is correct
61 Correct 209 ms 385616 KB Output is correct
62 Correct 207 ms 388852 KB Output is correct
63 Incorrect 1 ms 2396 KB Output isn't correct
64 Halted 0 ms 0 KB -