# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
208938 | 2020-03-12T15:42:42 Z | eriksuenderhauf | Collecting Stamps 3 (JOI20_ho_t3) | C++11 | 159 ms | 135416 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2e2 + 5; const ll inf = 0x3f3f3f3f3f3f3f3f; int X[N], T[N], n, l, ans = 0; ll dp[N][N][N][2]; ll dist(int i, int j) { return min(abs(X[i]-X[j]), l - abs(X[i]-X[j])); } void ckmn(ll& x, ll y) { x = min(x, y); } int main() { scanf("%d %d", &n, &l); for (int i = 1; i <= n; i++) scanf("%d", X+i); for (int i = 1; i <= n; i++) scanf("%d", T+i); memset(dp, 0x3f, sizeof dp); dp[0][0][0][0] = dp[0][0][0][1] = 0; for (int i = 0; i < n; i++) { for (int r = 0, l = i; r <= i; r++, l--) { ll v; for (int k = 0; k <= i; k++) { v = dp[l][r][k][0] + dist(n+1-l, n-l); ckmn(dp[l+1][r][k + (v <= T[n-l])][0], v); v = dp[l][r][k][0] + dist(n+1-l, r+1); ckmn(dp[l][r+1][k + (v <= T[r+1])][1], v); v = dp[l][r][k][1] + dist(r, n-l); ckmn(dp[l+1][r][k + (v <= T[n-l])][0], v); v = dp[l][r][k][1] + dist(r, r+1); ckmn(dp[l][r+1][k + (v <= T[r+1])][1], v); } } } for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) for (int k = 0; k <= n; k++) for (int f = 0; f < 2; f++) if (dp[i][j][k][f] != inf) ans = max(ans, k); printf("%d\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 82 ms | 135160 KB | Output is correct |
2 | Correct | 78 ms | 135160 KB | Output is correct |
3 | Correct | 78 ms | 135160 KB | Output is correct |
4 | Correct | 78 ms | 135160 KB | Output is correct |
5 | Correct | 78 ms | 135160 KB | Output is correct |
6 | Correct | 76 ms | 135160 KB | Output is correct |
7 | Correct | 78 ms | 135176 KB | Output is correct |
8 | Correct | 76 ms | 135160 KB | Output is correct |
9 | Correct | 77 ms | 135160 KB | Output is correct |
10 | Correct | 76 ms | 135160 KB | Output is correct |
11 | Correct | 79 ms | 135160 KB | Output is correct |
12 | Correct | 83 ms | 135288 KB | Output is correct |
13 | Correct | 77 ms | 135160 KB | Output is correct |
14 | Correct | 77 ms | 135160 KB | Output is correct |
15 | Correct | 77 ms | 135160 KB | Output is correct |
16 | Correct | 75 ms | 135160 KB | Output is correct |
17 | Correct | 83 ms | 135288 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 82 ms | 135160 KB | Output is correct |
2 | Correct | 78 ms | 135160 KB | Output is correct |
3 | Correct | 78 ms | 135160 KB | Output is correct |
4 | Correct | 78 ms | 135160 KB | Output is correct |
5 | Correct | 78 ms | 135160 KB | Output is correct |
6 | Correct | 76 ms | 135160 KB | Output is correct |
7 | Correct | 78 ms | 135176 KB | Output is correct |
8 | Correct | 76 ms | 135160 KB | Output is correct |
9 | Correct | 77 ms | 135160 KB | Output is correct |
10 | Correct | 76 ms | 135160 KB | Output is correct |
11 | Correct | 79 ms | 135160 KB | Output is correct |
12 | Correct | 83 ms | 135288 KB | Output is correct |
13 | Correct | 77 ms | 135160 KB | Output is correct |
14 | Correct | 77 ms | 135160 KB | Output is correct |
15 | Correct | 77 ms | 135160 KB | Output is correct |
16 | Correct | 75 ms | 135160 KB | Output is correct |
17 | Correct | 83 ms | 135288 KB | Output is correct |
18 | Correct | 80 ms | 135160 KB | Output is correct |
19 | Correct | 78 ms | 135220 KB | Output is correct |
20 | Correct | 77 ms | 135164 KB | Output is correct |
21 | Correct | 77 ms | 135160 KB | Output is correct |
22 | Correct | 80 ms | 135160 KB | Output is correct |
23 | Correct | 78 ms | 135160 KB | Output is correct |
24 | Correct | 77 ms | 135160 KB | Output is correct |
25 | Correct | 76 ms | 135160 KB | Output is correct |
26 | Correct | 76 ms | 135160 KB | Output is correct |
27 | Correct | 77 ms | 135160 KB | Output is correct |
28 | Correct | 77 ms | 135160 KB | Output is correct |
29 | Correct | 76 ms | 135160 KB | Output is correct |
30 | Correct | 76 ms | 135160 KB | Output is correct |
31 | Correct | 77 ms | 135136 KB | Output is correct |
32 | Correct | 76 ms | 135160 KB | Output is correct |
33 | Correct | 81 ms | 135416 KB | Output is correct |
34 | Correct | 77 ms | 135160 KB | Output is correct |
35 | Correct | 76 ms | 135156 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 82 ms | 135160 KB | Output is correct |
2 | Correct | 78 ms | 135160 KB | Output is correct |
3 | Correct | 78 ms | 135160 KB | Output is correct |
4 | Correct | 78 ms | 135160 KB | Output is correct |
5 | Correct | 78 ms | 135160 KB | Output is correct |
6 | Correct | 76 ms | 135160 KB | Output is correct |
7 | Correct | 78 ms | 135176 KB | Output is correct |
8 | Correct | 76 ms | 135160 KB | Output is correct |
9 | Correct | 77 ms | 135160 KB | Output is correct |
10 | Correct | 76 ms | 135160 KB | Output is correct |
11 | Correct | 79 ms | 135160 KB | Output is correct |
12 | Correct | 83 ms | 135288 KB | Output is correct |
13 | Correct | 77 ms | 135160 KB | Output is correct |
14 | Correct | 77 ms | 135160 KB | Output is correct |
15 | Correct | 77 ms | 135160 KB | Output is correct |
16 | Correct | 75 ms | 135160 KB | Output is correct |
17 | Correct | 83 ms | 135288 KB | Output is correct |
18 | Correct | 136 ms | 135164 KB | Output is correct |
19 | Correct | 109 ms | 135160 KB | Output is correct |
20 | Correct | 88 ms | 135160 KB | Output is correct |
21 | Correct | 104 ms | 135160 KB | Output is correct |
22 | Correct | 116 ms | 135160 KB | Output is correct |
23 | Correct | 87 ms | 135164 KB | Output is correct |
24 | Correct | 83 ms | 135160 KB | Output is correct |
25 | Correct | 87 ms | 135160 KB | Output is correct |
26 | Correct | 78 ms | 135160 KB | Output is correct |
27 | Correct | 94 ms | 135160 KB | Output is correct |
28 | Correct | 84 ms | 135160 KB | Output is correct |
29 | Correct | 89 ms | 135160 KB | Output is correct |
30 | Correct | 85 ms | 135160 KB | Output is correct |
31 | Correct | 86 ms | 135232 KB | Output is correct |
32 | Correct | 81 ms | 135160 KB | Output is correct |
33 | Correct | 88 ms | 135160 KB | Output is correct |
34 | Correct | 81 ms | 135224 KB | Output is correct |
35 | Correct | 86 ms | 135160 KB | Output is correct |
36 | Correct | 80 ms | 135160 KB | Output is correct |
37 | Correct | 86 ms | 135160 KB | Output is correct |
38 | Correct | 81 ms | 135160 KB | Output is correct |
39 | Correct | 91 ms | 135288 KB | Output is correct |
40 | Correct | 82 ms | 135160 KB | Output is correct |
41 | Correct | 153 ms | 135160 KB | Output is correct |
42 | Correct | 122 ms | 135164 KB | Output is correct |
43 | Correct | 155 ms | 135300 KB | Output is correct |
44 | Correct | 122 ms | 135160 KB | Output is correct |
45 | Correct | 155 ms | 135160 KB | Output is correct |
46 | Correct | 121 ms | 135164 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 82 ms | 135160 KB | Output is correct |
2 | Correct | 78 ms | 135160 KB | Output is correct |
3 | Correct | 78 ms | 135160 KB | Output is correct |
4 | Correct | 78 ms | 135160 KB | Output is correct |
5 | Correct | 78 ms | 135160 KB | Output is correct |
6 | Correct | 76 ms | 135160 KB | Output is correct |
7 | Correct | 78 ms | 135176 KB | Output is correct |
8 | Correct | 76 ms | 135160 KB | Output is correct |
9 | Correct | 77 ms | 135160 KB | Output is correct |
10 | Correct | 76 ms | 135160 KB | Output is correct |
11 | Correct | 79 ms | 135160 KB | Output is correct |
12 | Correct | 83 ms | 135288 KB | Output is correct |
13 | Correct | 77 ms | 135160 KB | Output is correct |
14 | Correct | 77 ms | 135160 KB | Output is correct |
15 | Correct | 77 ms | 135160 KB | Output is correct |
16 | Correct | 75 ms | 135160 KB | Output is correct |
17 | Correct | 83 ms | 135288 KB | Output is correct |
18 | Correct | 80 ms | 135160 KB | Output is correct |
19 | Correct | 78 ms | 135220 KB | Output is correct |
20 | Correct | 77 ms | 135164 KB | Output is correct |
21 | Correct | 77 ms | 135160 KB | Output is correct |
22 | Correct | 80 ms | 135160 KB | Output is correct |
23 | Correct | 78 ms | 135160 KB | Output is correct |
24 | Correct | 77 ms | 135160 KB | Output is correct |
25 | Correct | 76 ms | 135160 KB | Output is correct |
26 | Correct | 76 ms | 135160 KB | Output is correct |
27 | Correct | 77 ms | 135160 KB | Output is correct |
28 | Correct | 77 ms | 135160 KB | Output is correct |
29 | Correct | 76 ms | 135160 KB | Output is correct |
30 | Correct | 76 ms | 135160 KB | Output is correct |
31 | Correct | 77 ms | 135136 KB | Output is correct |
32 | Correct | 76 ms | 135160 KB | Output is correct |
33 | Correct | 81 ms | 135416 KB | Output is correct |
34 | Correct | 77 ms | 135160 KB | Output is correct |
35 | Correct | 76 ms | 135156 KB | Output is correct |
36 | Correct | 136 ms | 135164 KB | Output is correct |
37 | Correct | 109 ms | 135160 KB | Output is correct |
38 | Correct | 88 ms | 135160 KB | Output is correct |
39 | Correct | 104 ms | 135160 KB | Output is correct |
40 | Correct | 116 ms | 135160 KB | Output is correct |
41 | Correct | 87 ms | 135164 KB | Output is correct |
42 | Correct | 83 ms | 135160 KB | Output is correct |
43 | Correct | 87 ms | 135160 KB | Output is correct |
44 | Correct | 78 ms | 135160 KB | Output is correct |
45 | Correct | 94 ms | 135160 KB | Output is correct |
46 | Correct | 84 ms | 135160 KB | Output is correct |
47 | Correct | 89 ms | 135160 KB | Output is correct |
48 | Correct | 85 ms | 135160 KB | Output is correct |
49 | Correct | 86 ms | 135232 KB | Output is correct |
50 | Correct | 81 ms | 135160 KB | Output is correct |
51 | Correct | 88 ms | 135160 KB | Output is correct |
52 | Correct | 81 ms | 135224 KB | Output is correct |
53 | Correct | 86 ms | 135160 KB | Output is correct |
54 | Correct | 80 ms | 135160 KB | Output is correct |
55 | Correct | 86 ms | 135160 KB | Output is correct |
56 | Correct | 81 ms | 135160 KB | Output is correct |
57 | Correct | 91 ms | 135288 KB | Output is correct |
58 | Correct | 82 ms | 135160 KB | Output is correct |
59 | Correct | 153 ms | 135160 KB | Output is correct |
60 | Correct | 122 ms | 135164 KB | Output is correct |
61 | Correct | 155 ms | 135300 KB | Output is correct |
62 | Correct | 122 ms | 135160 KB | Output is correct |
63 | Correct | 155 ms | 135160 KB | Output is correct |
64 | Correct | 121 ms | 135164 KB | Output is correct |
65 | Correct | 149 ms | 135288 KB | Output is correct |
66 | Correct | 139 ms | 135160 KB | Output is correct |
67 | Correct | 136 ms | 135160 KB | Output is correct |
68 | Correct | 130 ms | 135160 KB | Output is correct |
69 | Correct | 148 ms | 135340 KB | Output is correct |
70 | Correct | 140 ms | 135160 KB | Output is correct |
71 | Correct | 140 ms | 135160 KB | Output is correct |
72 | Correct | 141 ms | 135160 KB | Output is correct |
73 | Correct | 141 ms | 135384 KB | Output is correct |
74 | Correct | 128 ms | 135164 KB | Output is correct |
75 | Correct | 138 ms | 135232 KB | Output is correct |
76 | Correct | 149 ms | 135160 KB | Output is correct |
77 | Correct | 155 ms | 135288 KB | Output is correct |
78 | Correct | 117 ms | 135160 KB | Output is correct |
79 | Correct | 131 ms | 135160 KB | Output is correct |
80 | Correct | 149 ms | 135160 KB | Output is correct |
81 | Correct | 140 ms | 135288 KB | Output is correct |
82 | Correct | 122 ms | 135160 KB | Output is correct |
83 | Correct | 155 ms | 135160 KB | Output is correct |
84 | Correct | 137 ms | 135164 KB | Output is correct |
85 | Correct | 153 ms | 135160 KB | Output is correct |
86 | Correct | 131 ms | 135160 KB | Output is correct |
87 | Correct | 138 ms | 135160 KB | Output is correct |
88 | Correct | 154 ms | 135160 KB | Output is correct |
89 | Correct | 154 ms | 135160 KB | Output is correct |
90 | Correct | 125 ms | 135160 KB | Output is correct |
91 | Correct | 154 ms | 135160 KB | Output is correct |
92 | Correct | 159 ms | 135160 KB | Output is correct |
93 | Correct | 152 ms | 135160 KB | Output is correct |