답안 #201950

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201950 2020-02-12T21:54:20 Z kuroni Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
420 ms 131576 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 205;
const long long INF = 1E18 + 7;

int n, l, cur, le, ri, ans = 0, x[N], d[N];
long long dst, dp[N][N][N][2];

void mini(long long &cur, long long tmp) {
    if (tmp < cur) {
        cur = tmp;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> l;
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> d[i];
    }
    n++;
    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] = INF;
            }
        }
    }
    dp[0][0][0][0] = 0;
    for (int k = 0; k < n; k++) {
        for (int len = 0; len < n; len++) {
            for (int i = 0; i < n; i++) {
                for (int t = 0; t < 2; t++) {
                    if (dp[i][len][k][t] == INF) {
                        continue;
                    }
                    cur = (t == 0 ? i : (i + len) % n);
                    le = (i + n - 1) % n;
                    ri = (i + len + 1) % n;
                    dst = min(l - abs(x[cur] - x[le]), abs(x[cur] - x[le])) + dp[i][len][k][t];
                    mini(dp[le][len + 1][k + (dst <= d[le])][0], dst);
                    dp[le][len + 1][k + (dst <= d[le])][0] = min(dp[le][len + 1][k + (dst <= d[le])][0], dst);
                    dst = min(l - abs(x[cur] - x[ri]), abs(x[cur] - x[ri])) + dp[i][len][k][t];
                    mini(dp[i][len + 1][k + (dst <= d[ri])][1], dst);
                    ans = max(ans, k);
                }
            }
        }
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 632 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 888 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 760 KB Output is correct
13 Correct 5 ms 888 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 5 ms 1016 KB Output is correct
17 Correct 5 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 632 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 888 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 760 KB Output is correct
13 Correct 5 ms 888 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 5 ms 1016 KB Output is correct
17 Correct 5 ms 888 KB Output is correct
18 Correct 5 ms 1144 KB Output is correct
19 Correct 5 ms 760 KB Output is correct
20 Correct 5 ms 888 KB Output is correct
21 Correct 5 ms 1144 KB Output is correct
22 Correct 5 ms 760 KB Output is correct
23 Correct 5 ms 1272 KB Output is correct
24 Correct 5 ms 1016 KB Output is correct
25 Correct 5 ms 1144 KB Output is correct
26 Correct 5 ms 1144 KB Output is correct
27 Correct 5 ms 636 KB Output is correct
28 Correct 5 ms 632 KB Output is correct
29 Correct 5 ms 1276 KB Output is correct
30 Correct 5 ms 1272 KB Output is correct
31 Correct 5 ms 1140 KB Output is correct
32 Correct 5 ms 1016 KB Output is correct
33 Correct 5 ms 1272 KB Output is correct
34 Correct 5 ms 1272 KB Output is correct
35 Correct 5 ms 1272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 632 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 888 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 760 KB Output is correct
13 Correct 5 ms 888 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 5 ms 1016 KB Output is correct
17 Correct 5 ms 888 KB Output is correct
18 Correct 224 ms 105492 KB Output is correct
19 Correct 106 ms 63992 KB Output is correct
20 Correct 44 ms 34296 KB Output is correct
21 Correct 93 ms 60536 KB Output is correct
22 Correct 134 ms 78328 KB Output is correct
23 Correct 41 ms 29304 KB Output is correct
24 Correct 26 ms 22904 KB Output is correct
25 Correct 40 ms 28664 KB Output is correct
26 Correct 13 ms 11000 KB Output is correct
27 Correct 42 ms 29944 KB Output is correct
28 Correct 26 ms 21240 KB Output is correct
29 Correct 41 ms 30456 KB Output is correct
30 Correct 27 ms 23928 KB Output is correct
31 Correct 38 ms 28664 KB Output is correct
32 Correct 18 ms 15096 KB Output is correct
33 Correct 36 ms 28664 KB Output is correct
34 Correct 12 ms 10360 KB Output is correct
35 Correct 31 ms 27896 KB Output is correct
36 Correct 15 ms 13432 KB Output is correct
37 Correct 35 ms 29944 KB Output is correct
38 Correct 19 ms 16376 KB Output is correct
39 Correct 34 ms 31096 KB Output is correct
40 Correct 21 ms 18296 KB Output is correct
41 Correct 331 ms 129912 KB Output is correct
42 Correct 121 ms 87544 KB Output is correct
43 Correct 327 ms 129936 KB Output is correct
44 Correct 116 ms 86264 KB Output is correct
45 Correct 334 ms 130040 KB Output is correct
46 Correct 117 ms 87288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 632 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 888 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 760 KB Output is correct
13 Correct 5 ms 888 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 5 ms 1016 KB Output is correct
17 Correct 5 ms 888 KB Output is correct
18 Correct 5 ms 1144 KB Output is correct
19 Correct 5 ms 760 KB Output is correct
20 Correct 5 ms 888 KB Output is correct
21 Correct 5 ms 1144 KB Output is correct
22 Correct 5 ms 760 KB Output is correct
23 Correct 5 ms 1272 KB Output is correct
24 Correct 5 ms 1016 KB Output is correct
25 Correct 5 ms 1144 KB Output is correct
26 Correct 5 ms 1144 KB Output is correct
27 Correct 5 ms 636 KB Output is correct
28 Correct 5 ms 632 KB Output is correct
29 Correct 5 ms 1276 KB Output is correct
30 Correct 5 ms 1272 KB Output is correct
31 Correct 5 ms 1140 KB Output is correct
32 Correct 5 ms 1016 KB Output is correct
33 Correct 5 ms 1272 KB Output is correct
34 Correct 5 ms 1272 KB Output is correct
35 Correct 5 ms 1272 KB Output is correct
36 Correct 224 ms 105492 KB Output is correct
37 Correct 106 ms 63992 KB Output is correct
38 Correct 44 ms 34296 KB Output is correct
39 Correct 93 ms 60536 KB Output is correct
40 Correct 134 ms 78328 KB Output is correct
41 Correct 41 ms 29304 KB Output is correct
42 Correct 26 ms 22904 KB Output is correct
43 Correct 40 ms 28664 KB Output is correct
44 Correct 13 ms 11000 KB Output is correct
45 Correct 42 ms 29944 KB Output is correct
46 Correct 26 ms 21240 KB Output is correct
47 Correct 41 ms 30456 KB Output is correct
48 Correct 27 ms 23928 KB Output is correct
49 Correct 38 ms 28664 KB Output is correct
50 Correct 18 ms 15096 KB Output is correct
51 Correct 36 ms 28664 KB Output is correct
52 Correct 12 ms 10360 KB Output is correct
53 Correct 31 ms 27896 KB Output is correct
54 Correct 15 ms 13432 KB Output is correct
55 Correct 35 ms 29944 KB Output is correct
56 Correct 19 ms 16376 KB Output is correct
57 Correct 34 ms 31096 KB Output is correct
58 Correct 21 ms 18296 KB Output is correct
59 Correct 331 ms 129912 KB Output is correct
60 Correct 121 ms 87544 KB Output is correct
61 Correct 327 ms 129936 KB Output is correct
62 Correct 116 ms 86264 KB Output is correct
63 Correct 334 ms 130040 KB Output is correct
64 Correct 117 ms 87288 KB Output is correct
65 Correct 282 ms 117240 KB Output is correct
66 Correct 227 ms 107820 KB Output is correct
67 Correct 196 ms 103032 KB Output is correct
68 Correct 179 ms 95096 KB Output is correct
69 Correct 262 ms 116088 KB Output is correct
70 Correct 247 ms 111480 KB Output is correct
71 Correct 226 ms 112376 KB Output is correct
72 Correct 267 ms 113916 KB Output is correct
73 Correct 185 ms 105208 KB Output is correct
74 Correct 198 ms 98936 KB Output is correct
75 Correct 224 ms 108792 KB Output is correct
76 Correct 323 ms 124920 KB Output is correct
77 Correct 307 ms 124792 KB Output is correct
78 Correct 186 ms 96376 KB Output is correct
79 Correct 187 ms 99576 KB Output is correct
80 Correct 334 ms 122616 KB Output is correct
81 Correct 188 ms 100600 KB Output is correct
82 Correct 179 ms 106360 KB Output is correct
83 Correct 341 ms 129992 KB Output is correct
84 Correct 206 ms 111096 KB Output is correct
85 Correct 249 ms 120824 KB Output is correct
86 Correct 244 ms 118520 KB Output is correct
87 Correct 216 ms 108792 KB Output is correct
88 Correct 397 ms 131576 KB Output is correct
89 Correct 332 ms 131192 KB Output is correct
90 Correct 169 ms 109688 KB Output is correct
91 Correct 379 ms 131448 KB Output is correct
92 Correct 420 ms 131200 KB Output is correct
93 Correct 235 ms 128376 KB Output is correct