# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
224049 | 2020-04-17T06:26:07 Z | shenxy | Collecting Stamps 3 (JOI20_ho_t3) | C++11 | 165 ms | 128760 KB |
#include <cstdio> #include <algorithm> #define int long long using namespace std; const int INF = 1000000000000000000; int N, L, X[202], T[202]; int dist[202][202][201][2]; int32_t main() { scanf("%lld %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[0] = 0; X[N + 1] = L; for (int i = 0; i < N + 2; ++i) { for (int j = 0; j < N + 2; ++j) dist[i][j][0][0] = dist[i][j][0][1] = INF; } dist[0][N + 1][0][0] = dist[0][N + 1][0][1] = 0; for (int i = 0; i <= N; ++i) { for (int j = i + 1; j < N + 2; ++j) { if (i == 0 && j == N + 1) continue; dist[i][j][0][0] = 2 * X[i] + L - X[j]; dist[i][j][0][1] = 2 * L - 2 * X[j] + X[i]; } } int ans = 0; for (int i = 1; i <= N; ++i) { for (int j = 0; j <= N; ++j) { for (int k = N + 1; k > j; --k) { dist[j][k][i][0] = dist[j][k][i][1] = INF; if (j != 0) dist[j][k][i][1] = min(dist[j][k][i][1], min(dist[j - 1][k][i][1] + X[j] - X[j - 1], dist[j - 1][k][i][0] + L - X[k] + X[j])); if (k != N + 1) dist[j][k][i][0] = min(dist[j][k][i][0], min(dist[j][k + 1][i][0] + X[k + 1] - X[k], dist[j][k + 1][i][1] + L - X[k] + X[j])); if (j != 0 && min(dist[j - 1][k][i - 1][1] + X[j] - X[j - 1], dist[j - 1][k][i - 1][0] + L - X[k] + X[j]) <= T[j]) dist[j][k][i][1] = min(dist[j][k][i][1], min(dist[j - 1][k][i - 1][1] + X[j] - X[j - 1], dist[j - 1][k][i - 1][0] + L - X[k] + X[j])); if (k != N + 1 && min(dist[j][k + 1][i - 1][0] + X[k + 1] - X[k], dist[j][k + 1][i - 1][1] + L - X[k] + X[j]) <= T[k]) dist[j][k][i][0] = min(dist[j][k][i][0], min(dist[j][k + 1][i - 1][0] + X[k + 1] - X[k], dist[j][k + 1][i - 1][1] + L - X[k] + X[j])); if (dist[j][k][i][0] < INF || dist[j][k][i][1] < INF) ans = max(ans, i); } } } printf("%lld", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 512 KB | Output is correct |
2 | Correct | 5 ms | 512 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 512 KB | Output is correct |
5 | Correct | 5 ms | 512 KB | Output is correct |
6 | Correct | 5 ms | 1024 KB | Output is correct |
7 | Correct | 6 ms | 640 KB | Output is correct |
8 | Correct | 5 ms | 768 KB | Output is correct |
9 | Correct | 5 ms | 1024 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 896 KB | Output is correct |
13 | Correct | 5 ms | 896 KB | Output is correct |
14 | Correct | 4 ms | 512 KB | Output is correct |
15 | Correct | 5 ms | 640 KB | Output is correct |
16 | Correct | 5 ms | 1024 KB | Output is correct |
17 | Correct | 5 ms | 896 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 512 KB | Output is correct |
2 | Correct | 5 ms | 512 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 512 KB | Output is correct |
5 | Correct | 5 ms | 512 KB | Output is correct |
6 | Correct | 5 ms | 1024 KB | Output is correct |
7 | Correct | 6 ms | 640 KB | Output is correct |
8 | Correct | 5 ms | 768 KB | Output is correct |
9 | Correct | 5 ms | 1024 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 896 KB | Output is correct |
13 | Correct | 5 ms | 896 KB | Output is correct |
14 | Correct | 4 ms | 512 KB | Output is correct |
15 | Correct | 5 ms | 640 KB | Output is correct |
16 | Correct | 5 ms | 1024 KB | Output is correct |
17 | Correct | 5 ms | 896 KB | Output is correct |
18 | Correct | 5 ms | 1152 KB | Output is correct |
19 | Correct | 5 ms | 768 KB | Output is correct |
20 | Correct | 5 ms | 1024 KB | Output is correct |
21 | Correct | 5 ms | 1152 KB | Output is correct |
22 | Correct | 5 ms | 640 KB | Output is correct |
23 | Correct | 5 ms | 1280 KB | Output is correct |
24 | Correct | 5 ms | 1024 KB | Output is correct |
25 | Correct | 5 ms | 1152 KB | Output is correct |
26 | Correct | 5 ms | 1152 KB | Output is correct |
27 | Correct | 5 ms | 640 KB | Output is correct |
28 | Correct | 5 ms | 768 KB | Output is correct |
29 | Correct | 5 ms | 1280 KB | Output is correct |
30 | Correct | 5 ms | 1280 KB | Output is correct |
31 | Correct | 5 ms | 1152 KB | Output is correct |
32 | Correct | 5 ms | 1152 KB | Output is correct |
33 | Correct | 5 ms | 1280 KB | Output is correct |
34 | Correct | 5 ms | 1280 KB | Output is correct |
35 | Correct | 5 ms | 1280 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 512 KB | Output is correct |
2 | Correct | 5 ms | 512 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 512 KB | Output is correct |
5 | Correct | 5 ms | 512 KB | Output is correct |
6 | Correct | 5 ms | 1024 KB | Output is correct |
7 | Correct | 6 ms | 640 KB | Output is correct |
8 | Correct | 5 ms | 768 KB | Output is correct |
9 | Correct | 5 ms | 1024 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 896 KB | Output is correct |
13 | Correct | 5 ms | 896 KB | Output is correct |
14 | Correct | 4 ms | 512 KB | Output is correct |
15 | Correct | 5 ms | 640 KB | Output is correct |
16 | Correct | 5 ms | 1024 KB | Output is correct |
17 | Correct | 5 ms | 896 KB | Output is correct |
18 | Correct | 94 ms | 104056 KB | Output is correct |
19 | Correct | 53 ms | 63352 KB | Output is correct |
20 | Correct | 27 ms | 34048 KB | Output is correct |
21 | Correct | 56 ms | 59896 KB | Output is correct |
22 | Correct | 67 ms | 77432 KB | Output is correct |
23 | Correct | 24 ms | 28928 KB | Output is correct |
24 | Correct | 20 ms | 22784 KB | Output is correct |
25 | Correct | 28 ms | 28416 KB | Output is correct |
26 | Correct | 10 ms | 11008 KB | Output is correct |
27 | Correct | 24 ms | 29568 KB | Output is correct |
28 | Correct | 21 ms | 21248 KB | Output is correct |
29 | Correct | 28 ms | 30208 KB | Output is correct |
30 | Correct | 22 ms | 23824 KB | Output is correct |
31 | Correct | 28 ms | 28416 KB | Output is correct |
32 | Correct | 14 ms | 15104 KB | Output is correct |
33 | Correct | 26 ms | 28416 KB | Output is correct |
34 | Correct | 10 ms | 10368 KB | Output is correct |
35 | Correct | 24 ms | 27776 KB | Output is correct |
36 | Correct | 14 ms | 13312 KB | Output is correct |
37 | Correct | 27 ms | 29568 KB | Output is correct |
38 | Correct | 17 ms | 16384 KB | Output is correct |
39 | Correct | 24 ms | 30848 KB | Output is correct |
40 | Correct | 16 ms | 18304 KB | Output is correct |
41 | Correct | 123 ms | 128108 KB | Output is correct |
42 | Correct | 72 ms | 86520 KB | Output is correct |
43 | Correct | 116 ms | 127992 KB | Output is correct |
44 | Correct | 81 ms | 85496 KB | Output is correct |
45 | Correct | 119 ms | 127992 KB | Output is correct |
46 | Correct | 71 ms | 86524 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 512 KB | Output is correct |
2 | Correct | 5 ms | 512 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 512 KB | Output is correct |
5 | Correct | 5 ms | 512 KB | Output is correct |
6 | Correct | 5 ms | 1024 KB | Output is correct |
7 | Correct | 6 ms | 640 KB | Output is correct |
8 | Correct | 5 ms | 768 KB | Output is correct |
9 | Correct | 5 ms | 1024 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 896 KB | Output is correct |
13 | Correct | 5 ms | 896 KB | Output is correct |
14 | Correct | 4 ms | 512 KB | Output is correct |
15 | Correct | 5 ms | 640 KB | Output is correct |
16 | Correct | 5 ms | 1024 KB | Output is correct |
17 | Correct | 5 ms | 896 KB | Output is correct |
18 | Correct | 5 ms | 1152 KB | Output is correct |
19 | Correct | 5 ms | 768 KB | Output is correct |
20 | Correct | 5 ms | 1024 KB | Output is correct |
21 | Correct | 5 ms | 1152 KB | Output is correct |
22 | Correct | 5 ms | 640 KB | Output is correct |
23 | Correct | 5 ms | 1280 KB | Output is correct |
24 | Correct | 5 ms | 1024 KB | Output is correct |
25 | Correct | 5 ms | 1152 KB | Output is correct |
26 | Correct | 5 ms | 1152 KB | Output is correct |
27 | Correct | 5 ms | 640 KB | Output is correct |
28 | Correct | 5 ms | 768 KB | Output is correct |
29 | Correct | 5 ms | 1280 KB | Output is correct |
30 | Correct | 5 ms | 1280 KB | Output is correct |
31 | Correct | 5 ms | 1152 KB | Output is correct |
32 | Correct | 5 ms | 1152 KB | Output is correct |
33 | Correct | 5 ms | 1280 KB | Output is correct |
34 | Correct | 5 ms | 1280 KB | Output is correct |
35 | Correct | 5 ms | 1280 KB | Output is correct |
36 | Correct | 94 ms | 104056 KB | Output is correct |
37 | Correct | 53 ms | 63352 KB | Output is correct |
38 | Correct | 27 ms | 34048 KB | Output is correct |
39 | Correct | 56 ms | 59896 KB | Output is correct |
40 | Correct | 67 ms | 77432 KB | Output is correct |
41 | Correct | 24 ms | 28928 KB | Output is correct |
42 | Correct | 20 ms | 22784 KB | Output is correct |
43 | Correct | 28 ms | 28416 KB | Output is correct |
44 | Correct | 10 ms | 11008 KB | Output is correct |
45 | Correct | 24 ms | 29568 KB | Output is correct |
46 | Correct | 21 ms | 21248 KB | Output is correct |
47 | Correct | 28 ms | 30208 KB | Output is correct |
48 | Correct | 22 ms | 23824 KB | Output is correct |
49 | Correct | 28 ms | 28416 KB | Output is correct |
50 | Correct | 14 ms | 15104 KB | Output is correct |
51 | Correct | 26 ms | 28416 KB | Output is correct |
52 | Correct | 10 ms | 10368 KB | Output is correct |
53 | Correct | 24 ms | 27776 KB | Output is correct |
54 | Correct | 14 ms | 13312 KB | Output is correct |
55 | Correct | 27 ms | 29568 KB | Output is correct |
56 | Correct | 17 ms | 16384 KB | Output is correct |
57 | Correct | 24 ms | 30848 KB | Output is correct |
58 | Correct | 16 ms | 18304 KB | Output is correct |
59 | Correct | 123 ms | 128108 KB | Output is correct |
60 | Correct | 72 ms | 86520 KB | Output is correct |
61 | Correct | 116 ms | 127992 KB | Output is correct |
62 | Correct | 81 ms | 85496 KB | Output is correct |
63 | Correct | 119 ms | 127992 KB | Output is correct |
64 | Correct | 71 ms | 86524 KB | Output is correct |
65 | Correct | 106 ms | 115832 KB | Output is correct |
66 | Correct | 111 ms | 106360 KB | Output is correct |
67 | Correct | 112 ms | 101752 KB | Output is correct |
68 | Correct | 80 ms | 94060 KB | Output is correct |
69 | Correct | 104 ms | 114552 KB | Output is correct |
70 | Correct | 118 ms | 109816 KB | Output is correct |
71 | Correct | 100 ms | 111096 KB | Output is correct |
72 | Correct | 101 ms | 112376 KB | Output is correct |
73 | Correct | 91 ms | 104056 KB | Output is correct |
74 | Correct | 85 ms | 97400 KB | Output is correct |
75 | Correct | 95 ms | 107512 KB | Output is correct |
76 | Correct | 116 ms | 123256 KB | Output is correct |
77 | Correct | 114 ms | 123144 KB | Output is correct |
78 | Correct | 82 ms | 95096 KB | Output is correct |
79 | Correct | 91 ms | 98424 KB | Output is correct |
80 | Correct | 113 ms | 120824 KB | Output is correct |
81 | Correct | 89 ms | 99576 KB | Output is correct |
82 | Correct | 96 ms | 105168 KB | Output is correct |
83 | Correct | 117 ms | 128124 KB | Output is correct |
84 | Correct | 96 ms | 109816 KB | Output is correct |
85 | Correct | 108 ms | 119544 KB | Output is correct |
86 | Correct | 105 ms | 117112 KB | Output is correct |
87 | Correct | 109 ms | 107672 KB | Output is correct |
88 | Correct | 131 ms | 128760 KB | Output is correct |
89 | Correct | 165 ms | 128632 KB | Output is correct |
90 | Correct | 97 ms | 108760 KB | Output is correct |
91 | Correct | 143 ms | 128760 KB | Output is correct |
92 | Correct | 142 ms | 128760 KB | Output is correct |
93 | Correct | 116 ms | 126968 KB | Output is correct |