# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
244949 | 2020-07-05T09:55:51 Z | maximath_1 | Collecting Stamps 3 (JOI20_ho_t3) | C++11 | 136 ms | 135288 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const ll inf = 1e18; ll x[205], t[205], l, dp[205][205][205][2]; int n; int main(){ scanf("%d%lld", &n, &l); for(int i = 1; i <= n; i ++) scanf("%lld", &x[i]); for(int i = 1; i <= n; i ++) scanf("%lld", &t[i]); x[n + 1] = l; for(int i = 0; i < n + 5; i ++) for(int j = 0; j < n + 5; j ++) for(int k = 0; k < n + 5; k ++) for(int a = 0; a < 2; a ++) dp[i][j][k][a] = inf + 5ll; dp[0][0][0][0] = 0ll; for(int i = 0; i < n; i ++) for(int j = 0; i + j < n; j ++) for(int k = 0; k <= i + j; k ++){ ll tim; if(dp[i][j][k][0] < inf){ tim = dp[i][j][k][0] + x[i + 1] - x[i]; dp[i + 1][j][k + (t[i + 1] >= tim)][0] = min(dp[i + 1][j][k + (t[i + 1] >= tim)][0], tim); tim = dp[i][j][k][0] + x[i] + l - x[n - j]; dp[i][j + 1][k + (t[n - j] >= tim)][1] = min(dp[i][j + 1][k + (t[n - j] >= tim)][1], tim); } if(dp[i][j][k][1] < inf){ tim = dp[i][j][k][1] + x[n - j + 1] - x[n -j]; dp[i][j + 1][k + (t[n - j] >= tim)][1] = min(dp[i][j + 1][k + (t[n - j] >= tim)][1], tim); tim = dp[i][j][k][1] + l - x[n - j + 1] + x[i + 1]; dp[i + 1][j][k + (t[i + 1] >= tim)][0] = min(dp[i + 1][j][k + (t[i + 1] >= tim)][0], tim); } } int ans = 0; for(int i = 0; i <= n; i ++) for(int j = 0; i + j <= n; j ++) for(int k = 0; k <= i + j; k ++){ if(min(dp[i][j][k][0], dp[i][j][k][1]) < inf) ans = max(ans, k); } printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 640 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
3 | Correct | 5 ms | 1024 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 5 ms | 1280 KB | Output is correct |
7 | Correct | 5 ms | 896 KB | Output is correct |
8 | Correct | 5 ms | 1024 KB | Output is correct |
9 | Correct | 5 ms | 1280 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 1280 KB | Output is correct |
13 | Correct | 5 ms | 1280 KB | Output is correct |
14 | Correct | 5 ms | 768 KB | Output is correct |
15 | Correct | 5 ms | 896 KB | Output is correct |
16 | Correct | 5 ms | 1280 KB | Output is correct |
17 | Correct | 5 ms | 1280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 640 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
3 | Correct | 5 ms | 1024 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 5 ms | 1280 KB | Output is correct |
7 | Correct | 5 ms | 896 KB | Output is correct |
8 | Correct | 5 ms | 1024 KB | Output is correct |
9 | Correct | 5 ms | 1280 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 1280 KB | Output is correct |
13 | Correct | 5 ms | 1280 KB | Output is correct |
14 | Correct | 5 ms | 768 KB | Output is correct |
15 | Correct | 5 ms | 896 KB | Output is correct |
16 | Correct | 5 ms | 1280 KB | Output is correct |
17 | Correct | 5 ms | 1280 KB | Output is correct |
18 | Correct | 5 ms | 1536 KB | Output is correct |
19 | Correct | 5 ms | 1024 KB | Output is correct |
20 | Correct | 5 ms | 1280 KB | Output is correct |
21 | Correct | 5 ms | 1536 KB | Output is correct |
22 | Correct | 5 ms | 1024 KB | Output is correct |
23 | Correct | 5 ms | 1664 KB | Output is correct |
24 | Correct | 5 ms | 1408 KB | Output is correct |
25 | Correct | 5 ms | 1536 KB | Output is correct |
26 | Correct | 5 ms | 1536 KB | Output is correct |
27 | Correct | 5 ms | 896 KB | Output is correct |
28 | Correct | 5 ms | 1024 KB | Output is correct |
29 | Correct | 5 ms | 1664 KB | Output is correct |
30 | Correct | 5 ms | 1664 KB | Output is correct |
31 | Correct | 5 ms | 1536 KB | Output is correct |
32 | Correct | 5 ms | 1408 KB | Output is correct |
33 | Correct | 5 ms | 1664 KB | Output is correct |
34 | Correct | 5 ms | 1664 KB | Output is correct |
35 | Correct | 5 ms | 1664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 640 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
3 | Correct | 5 ms | 1024 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 5 ms | 1280 KB | Output is correct |
7 | Correct | 5 ms | 896 KB | Output is correct |
8 | Correct | 5 ms | 1024 KB | Output is correct |
9 | Correct | 5 ms | 1280 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 1280 KB | Output is correct |
13 | Correct | 5 ms | 1280 KB | Output is correct |
14 | Correct | 5 ms | 768 KB | Output is correct |
15 | Correct | 5 ms | 896 KB | Output is correct |
16 | Correct | 5 ms | 1280 KB | Output is correct |
17 | Correct | 5 ms | 1280 KB | Output is correct |
18 | Correct | 90 ms | 109688 KB | Output is correct |
19 | Correct | 53 ms | 67328 KB | Output is correct |
20 | Correct | 27 ms | 36736 KB | Output is correct |
21 | Correct | 50 ms | 63744 KB | Output is correct |
22 | Correct | 72 ms | 82060 KB | Output is correct |
23 | Correct | 26 ms | 31488 KB | Output is correct |
24 | Correct | 20 ms | 24960 KB | Output is correct |
25 | Correct | 26 ms | 30848 KB | Output is correct |
26 | Correct | 11 ms | 12416 KB | Output is correct |
27 | Correct | 28 ms | 32128 KB | Output is correct |
28 | Correct | 17 ms | 23168 KB | Output is correct |
29 | Correct | 27 ms | 32768 KB | Output is correct |
30 | Correct | 22 ms | 26112 KB | Output is correct |
31 | Correct | 25 ms | 30848 KB | Output is correct |
32 | Correct | 13 ms | 16640 KB | Output is correct |
33 | Correct | 24 ms | 30848 KB | Output is correct |
34 | Correct | 11 ms | 11648 KB | Output is correct |
35 | Correct | 21 ms | 30208 KB | Output is correct |
36 | Correct | 12 ms | 14976 KB | Output is correct |
37 | Correct | 24 ms | 32128 KB | Output is correct |
38 | Correct | 15 ms | 18048 KB | Output is correct |
39 | Correct | 26 ms | 33408 KB | Output is correct |
40 | Correct | 15 ms | 20096 KB | Output is correct |
41 | Correct | 119 ms | 134520 KB | Output is correct |
42 | Correct | 55 ms | 91512 KB | Output is correct |
43 | Correct | 119 ms | 134520 KB | Output is correct |
44 | Correct | 54 ms | 90488 KB | Output is correct |
45 | Correct | 123 ms | 134520 KB | Output is correct |
46 | Correct | 63 ms | 91512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 640 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
3 | Correct | 5 ms | 1024 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 5 ms | 1280 KB | Output is correct |
7 | Correct | 5 ms | 896 KB | Output is correct |
8 | Correct | 5 ms | 1024 KB | Output is correct |
9 | Correct | 5 ms | 1280 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 1280 KB | Output is correct |
13 | Correct | 5 ms | 1280 KB | Output is correct |
14 | Correct | 5 ms | 768 KB | Output is correct |
15 | Correct | 5 ms | 896 KB | Output is correct |
16 | Correct | 5 ms | 1280 KB | Output is correct |
17 | Correct | 5 ms | 1280 KB | Output is correct |
18 | Correct | 5 ms | 1536 KB | Output is correct |
19 | Correct | 5 ms | 1024 KB | Output is correct |
20 | Correct | 5 ms | 1280 KB | Output is correct |
21 | Correct | 5 ms | 1536 KB | Output is correct |
22 | Correct | 5 ms | 1024 KB | Output is correct |
23 | Correct | 5 ms | 1664 KB | Output is correct |
24 | Correct | 5 ms | 1408 KB | Output is correct |
25 | Correct | 5 ms | 1536 KB | Output is correct |
26 | Correct | 5 ms | 1536 KB | Output is correct |
27 | Correct | 5 ms | 896 KB | Output is correct |
28 | Correct | 5 ms | 1024 KB | Output is correct |
29 | Correct | 5 ms | 1664 KB | Output is correct |
30 | Correct | 5 ms | 1664 KB | Output is correct |
31 | Correct | 5 ms | 1536 KB | Output is correct |
32 | Correct | 5 ms | 1408 KB | Output is correct |
33 | Correct | 5 ms | 1664 KB | Output is correct |
34 | Correct | 5 ms | 1664 KB | Output is correct |
35 | Correct | 5 ms | 1664 KB | Output is correct |
36 | Correct | 90 ms | 109688 KB | Output is correct |
37 | Correct | 53 ms | 67328 KB | Output is correct |
38 | Correct | 27 ms | 36736 KB | Output is correct |
39 | Correct | 50 ms | 63744 KB | Output is correct |
40 | Correct | 72 ms | 82060 KB | Output is correct |
41 | Correct | 26 ms | 31488 KB | Output is correct |
42 | Correct | 20 ms | 24960 KB | Output is correct |
43 | Correct | 26 ms | 30848 KB | Output is correct |
44 | Correct | 11 ms | 12416 KB | Output is correct |
45 | Correct | 28 ms | 32128 KB | Output is correct |
46 | Correct | 17 ms | 23168 KB | Output is correct |
47 | Correct | 27 ms | 32768 KB | Output is correct |
48 | Correct | 22 ms | 26112 KB | Output is correct |
49 | Correct | 25 ms | 30848 KB | Output is correct |
50 | Correct | 13 ms | 16640 KB | Output is correct |
51 | Correct | 24 ms | 30848 KB | Output is correct |
52 | Correct | 11 ms | 11648 KB | Output is correct |
53 | Correct | 21 ms | 30208 KB | Output is correct |
54 | Correct | 12 ms | 14976 KB | Output is correct |
55 | Correct | 24 ms | 32128 KB | Output is correct |
56 | Correct | 15 ms | 18048 KB | Output is correct |
57 | Correct | 26 ms | 33408 KB | Output is correct |
58 | Correct | 15 ms | 20096 KB | Output is correct |
59 | Correct | 119 ms | 134520 KB | Output is correct |
60 | Correct | 55 ms | 91512 KB | Output is correct |
61 | Correct | 119 ms | 134520 KB | Output is correct |
62 | Correct | 54 ms | 90488 KB | Output is correct |
63 | Correct | 123 ms | 134520 KB | Output is correct |
64 | Correct | 63 ms | 91512 KB | Output is correct |
65 | Correct | 104 ms | 121848 KB | Output is correct |
66 | Correct | 94 ms | 111992 KB | Output is correct |
67 | Correct | 88 ms | 107128 KB | Output is correct |
68 | Correct | 78 ms | 99252 KB | Output is correct |
69 | Correct | 103 ms | 120568 KB | Output is correct |
70 | Correct | 101 ms | 115704 KB | Output is correct |
71 | Correct | 92 ms | 116984 KB | Output is correct |
72 | Correct | 119 ms | 118208 KB | Output is correct |
73 | Correct | 90 ms | 109816 KB | Output is correct |
74 | Correct | 91 ms | 102648 KB | Output is correct |
75 | Correct | 93 ms | 113400 KB | Output is correct |
76 | Correct | 119 ms | 129656 KB | Output is correct |
77 | Correct | 107 ms | 129528 KB | Output is correct |
78 | Correct | 97 ms | 100344 KB | Output is correct |
79 | Correct | 93 ms | 103800 KB | Output is correct |
80 | Correct | 109 ms | 126968 KB | Output is correct |
81 | Correct | 85 ms | 105020 KB | Output is correct |
82 | Correct | 83 ms | 110904 KB | Output is correct |
83 | Correct | 108 ms | 134520 KB | Output is correct |
84 | Correct | 85 ms | 115704 KB | Output is correct |
85 | Correct | 115 ms | 125688 KB | Output is correct |
86 | Correct | 93 ms | 123128 KB | Output is correct |
87 | Correct | 96 ms | 113272 KB | Output is correct |
88 | Correct | 136 ms | 135288 KB | Output is correct |
89 | Correct | 130 ms | 135160 KB | Output is correct |
90 | Correct | 82 ms | 114424 KB | Output is correct |
91 | Correct | 132 ms | 135160 KB | Output is correct |
92 | Correct | 122 ms | 135160 KB | Output is correct |
93 | Correct | 82 ms | 133368 KB | Output is correct |