# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
564090 | 2022-05-18T14:31:49 Z | hibiki | Collecting Stamps 3 (JOI20_ho_t3) | C++11 | 117 ms | 130820 KB |
#include<bits/stdc++.h> using namespace std; long long n,l; long long xl[205],xr[205],lt[205],rt[205]; long long dp[205][205][205][2]; int main() { scanf("%lld %lld",&n,&l); for(int i = 1; i <= n; i++) { scanf("%lld",&xr[i]); xl[n - i + 1] = l - xr[i]; } for(int i = 1; i <= n; i++) { scanf("%lld",&rt[i]); lt[n - i + 1] = rt[i]; } for(int i = 0; i <= n; 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] = 1e18; dp[0][0][0][0] = dp[0][0][0][1] = 0; int ans = 0; for(int k = 0; k <= n; k++) { for(int i = 0; i <= n; i++) { for(int j = 0; j <= n; j++) { if(i + j > n) continue; if(dp[i][j][k][0] != 1e18 || dp[i][j][k][1] != 1e18) ans = max(ans,k); long long nw_t; if(i + 1 <= n) { // left to left nw_t = dp[i][j][k][0]; nw_t += xl[i + 1] - xl[i]; if(nw_t <= lt[i + 1]) dp[i + 1][j][k + 1][0] = min(dp[i + 1][j][k + 1][0], nw_t); else dp[i + 1][j][k][0] = min(dp[i + 1][j][k][0], nw_t); // right to left nw_t = dp[i][j][k][1]; nw_t += xl[i + 1] + xr[j]; if(nw_t <= lt[i + 1]) dp[i + 1][j][k + 1][0] = min(dp[i + 1][j][k + 1][0], nw_t); else dp[i + 1][j][k][0] = min(dp[i + 1][j][k][0], nw_t); } if(j + 1 <= n) { // left to right nw_t = dp[i][j][k][0]; nw_t += xr[j + 1] + xl[i]; if(nw_t <= rt[j + 1]) dp[i][j + 1][k + 1][1] = min(dp[i][j + 1][k + 1][1], nw_t); else dp[i][j + 1][k][1] = min(dp[i][j + 1][k][1], nw_t); // right to right nw_t = dp[i][j][k][1]; nw_t += xr[j + 1] - xr[j]; if(nw_t <= rt[j + 1]) dp[i][j + 1][k + 1][1] = min(dp[i][j + 1][k + 1][1], nw_t); else dp[i][j + 1][k][1] = min(dp[i][j + 1][k][1], nw_t); } } } } printf("%d\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 444 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 852 KB | Output is correct |
7 | Correct | 1 ms | 468 KB | Output is correct |
8 | Correct | 1 ms | 724 KB | Output is correct |
9 | Correct | 1 ms | 852 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 852 KB | Output is correct |
13 | Correct | 1 ms | 852 KB | Output is correct |
14 | Correct | 1 ms | 468 KB | Output is correct |
15 | Correct | 1 ms | 596 KB | Output is correct |
16 | Correct | 1 ms | 824 KB | Output is correct |
17 | Correct | 1 ms | 852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 444 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 852 KB | Output is correct |
7 | Correct | 1 ms | 468 KB | Output is correct |
8 | Correct | 1 ms | 724 KB | Output is correct |
9 | Correct | 1 ms | 852 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 852 KB | Output is correct |
13 | Correct | 1 ms | 852 KB | Output is correct |
14 | Correct | 1 ms | 468 KB | Output is correct |
15 | Correct | 1 ms | 596 KB | Output is correct |
16 | Correct | 1 ms | 824 KB | Output is correct |
17 | Correct | 1 ms | 852 KB | Output is correct |
18 | Correct | 1 ms | 980 KB | Output is correct |
19 | Correct | 1 ms | 724 KB | Output is correct |
20 | Correct | 1 ms | 852 KB | Output is correct |
21 | Correct | 1 ms | 980 KB | Output is correct |
22 | Correct | 1 ms | 596 KB | Output is correct |
23 | Correct | 1 ms | 1108 KB | Output is correct |
24 | Correct | 1 ms | 852 KB | Output is correct |
25 | Correct | 1 ms | 980 KB | Output is correct |
26 | Correct | 1 ms | 980 KB | Output is correct |
27 | Correct | 1 ms | 468 KB | Output is correct |
28 | Correct | 1 ms | 596 KB | Output is correct |
29 | Correct | 1 ms | 1108 KB | Output is correct |
30 | Correct | 1 ms | 1108 KB | Output is correct |
31 | Correct | 1 ms | 980 KB | Output is correct |
32 | Correct | 1 ms | 956 KB | Output is correct |
33 | Correct | 1 ms | 1108 KB | Output is correct |
34 | Correct | 1 ms | 1108 KB | Output is correct |
35 | Correct | 1 ms | 1108 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 444 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 852 KB | Output is correct |
7 | Correct | 1 ms | 468 KB | Output is correct |
8 | Correct | 1 ms | 724 KB | Output is correct |
9 | Correct | 1 ms | 852 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 852 KB | Output is correct |
13 | Correct | 1 ms | 852 KB | Output is correct |
14 | Correct | 1 ms | 468 KB | Output is correct |
15 | Correct | 1 ms | 596 KB | Output is correct |
16 | Correct | 1 ms | 824 KB | Output is correct |
17 | Correct | 1 ms | 852 KB | Output is correct |
18 | Correct | 77 ms | 104876 KB | Output is correct |
19 | Correct | 44 ms | 63620 KB | Output is correct |
20 | Correct | 22 ms | 34004 KB | Output is correct |
21 | Correct | 41 ms | 60104 KB | Output is correct |
22 | Correct | 53 ms | 77948 KB | Output is correct |
23 | Correct | 18 ms | 28884 KB | Output is correct |
24 | Correct | 14 ms | 22612 KB | Output is correct |
25 | Correct | 19 ms | 28244 KB | Output is correct |
26 | Correct | 6 ms | 10836 KB | Output is correct |
27 | Correct | 19 ms | 29556 KB | Output is correct |
28 | Correct | 13 ms | 21076 KB | Output is correct |
29 | Correct | 19 ms | 30164 KB | Output is correct |
30 | Correct | 16 ms | 23736 KB | Output is correct |
31 | Correct | 20 ms | 28340 KB | Output is correct |
32 | Correct | 10 ms | 14804 KB | Output is correct |
33 | Correct | 19 ms | 28276 KB | Output is correct |
34 | Correct | 6 ms | 10068 KB | Output is correct |
35 | Correct | 19 ms | 27744 KB | Output is correct |
36 | Correct | 8 ms | 13112 KB | Output is correct |
37 | Correct | 19 ms | 29524 KB | Output is correct |
38 | Correct | 10 ms | 16212 KB | Output is correct |
39 | Correct | 20 ms | 30676 KB | Output is correct |
40 | Correct | 12 ms | 18004 KB | Output is correct |
41 | Correct | 117 ms | 129420 KB | Output is correct |
42 | Correct | 67 ms | 87216 KB | Output is correct |
43 | Correct | 115 ms | 129444 KB | Output is correct |
44 | Correct | 63 ms | 86152 KB | Output is correct |
45 | Correct | 109 ms | 129376 KB | Output is correct |
46 | Correct | 67 ms | 87192 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 444 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 852 KB | Output is correct |
7 | Correct | 1 ms | 468 KB | Output is correct |
8 | Correct | 1 ms | 724 KB | Output is correct |
9 | Correct | 1 ms | 852 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 852 KB | Output is correct |
13 | Correct | 1 ms | 852 KB | Output is correct |
14 | Correct | 1 ms | 468 KB | Output is correct |
15 | Correct | 1 ms | 596 KB | Output is correct |
16 | Correct | 1 ms | 824 KB | Output is correct |
17 | Correct | 1 ms | 852 KB | Output is correct |
18 | Correct | 1 ms | 980 KB | Output is correct |
19 | Correct | 1 ms | 724 KB | Output is correct |
20 | Correct | 1 ms | 852 KB | Output is correct |
21 | Correct | 1 ms | 980 KB | Output is correct |
22 | Correct | 1 ms | 596 KB | Output is correct |
23 | Correct | 1 ms | 1108 KB | Output is correct |
24 | Correct | 1 ms | 852 KB | Output is correct |
25 | Correct | 1 ms | 980 KB | Output is correct |
26 | Correct | 1 ms | 980 KB | Output is correct |
27 | Correct | 1 ms | 468 KB | Output is correct |
28 | Correct | 1 ms | 596 KB | Output is correct |
29 | Correct | 1 ms | 1108 KB | Output is correct |
30 | Correct | 1 ms | 1108 KB | Output is correct |
31 | Correct | 1 ms | 980 KB | Output is correct |
32 | Correct | 1 ms | 956 KB | Output is correct |
33 | Correct | 1 ms | 1108 KB | Output is correct |
34 | Correct | 1 ms | 1108 KB | Output is correct |
35 | Correct | 1 ms | 1108 KB | Output is correct |
36 | Correct | 77 ms | 104876 KB | Output is correct |
37 | Correct | 44 ms | 63620 KB | Output is correct |
38 | Correct | 22 ms | 34004 KB | Output is correct |
39 | Correct | 41 ms | 60104 KB | Output is correct |
40 | Correct | 53 ms | 77948 KB | Output is correct |
41 | Correct | 18 ms | 28884 KB | Output is correct |
42 | Correct | 14 ms | 22612 KB | Output is correct |
43 | Correct | 19 ms | 28244 KB | Output is correct |
44 | Correct | 6 ms | 10836 KB | Output is correct |
45 | Correct | 19 ms | 29556 KB | Output is correct |
46 | Correct | 13 ms | 21076 KB | Output is correct |
47 | Correct | 19 ms | 30164 KB | Output is correct |
48 | Correct | 16 ms | 23736 KB | Output is correct |
49 | Correct | 20 ms | 28340 KB | Output is correct |
50 | Correct | 10 ms | 14804 KB | Output is correct |
51 | Correct | 19 ms | 28276 KB | Output is correct |
52 | Correct | 6 ms | 10068 KB | Output is correct |
53 | Correct | 19 ms | 27744 KB | Output is correct |
54 | Correct | 8 ms | 13112 KB | Output is correct |
55 | Correct | 19 ms | 29524 KB | Output is correct |
56 | Correct | 10 ms | 16212 KB | Output is correct |
57 | Correct | 20 ms | 30676 KB | Output is correct |
58 | Correct | 12 ms | 18004 KB | Output is correct |
59 | Correct | 117 ms | 129420 KB | Output is correct |
60 | Correct | 67 ms | 87216 KB | Output is correct |
61 | Correct | 115 ms | 129444 KB | Output is correct |
62 | Correct | 63 ms | 86152 KB | Output is correct |
63 | Correct | 109 ms | 129376 KB | Output is correct |
64 | Correct | 67 ms | 87192 KB | Output is correct |
65 | Correct | 89 ms | 116876 KB | Output is correct |
66 | Correct | 84 ms | 107196 KB | Output is correct |
67 | Correct | 74 ms | 102564 KB | Output is correct |
68 | Correct | 68 ms | 94740 KB | Output is correct |
69 | Correct | 90 ms | 115760 KB | Output is correct |
70 | Correct | 98 ms | 110828 KB | Output is correct |
71 | Correct | 84 ms | 112028 KB | Output is correct |
72 | Correct | 84 ms | 113232 KB | Output is correct |
73 | Correct | 77 ms | 104932 KB | Output is correct |
74 | Correct | 76 ms | 97984 KB | Output is correct |
75 | Correct | 79 ms | 108344 KB | Output is correct |
76 | Correct | 107 ms | 124348 KB | Output is correct |
77 | Correct | 94 ms | 124352 KB | Output is correct |
78 | Correct | 71 ms | 95848 KB | Output is correct |
79 | Correct | 77 ms | 99260 KB | Output is correct |
80 | Correct | 97 ms | 121800 KB | Output is correct |
81 | Correct | 78 ms | 100440 KB | Output is correct |
82 | Correct | 78 ms | 106060 KB | Output is correct |
83 | Correct | 101 ms | 129452 KB | Output is correct |
84 | Correct | 88 ms | 110796 KB | Output is correct |
85 | Correct | 95 ms | 120496 KB | Output is correct |
86 | Correct | 89 ms | 118088 KB | Output is correct |
87 | Correct | 93 ms | 108408 KB | Output is correct |
88 | Correct | 105 ms | 130728 KB | Output is correct |
89 | Correct | 103 ms | 130676 KB | Output is correct |
90 | Correct | 85 ms | 109556 KB | Output is correct |
91 | Correct | 102 ms | 130820 KB | Output is correct |
92 | Correct | 104 ms | 130668 KB | Output is correct |
93 | Correct | 99 ms | 128052 KB | Output is correct |