답안 #563662

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563662 2022-05-17T21:16:25 Z 4fecta Collecting Stamps 3 (JOI20_ho_t3) C++17
15 / 100
664 ms 135316 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define boost() cin.tie(0), cin.sync_with_stdio(0)

const int MN = 205;

int n, L, x[MN], t[MN], dp[MN][MN][MN][2], ans; //left, right, how many, left/right = min time

int d(int i, int j) {
    i %= (n + 1), j %= (n + 1);
    if (i < j) swap(i, j);
    int p1 = L - x[i] + x[j], p2 = L - p1;
    return min(p1, p2);
}

int rec(int l, int r, int k, int s) {
    l %= (n + 1), r %= (n + 1);
    //printf("%d %d %d %d\n", l, r, k, s);
    if (dp[l][r][k][s] != -1) return dp[l][r][k][s];
    int bst = 1e12;
    if (!s && l > 0) {
        bst = min(bst, rec(l + 1, r, k, 1) + d(l, r));
        bst = min(bst, rec(l + 1, r, k, 0) + d(l, l + 1));
        if (k) {
            int v1 = rec(l + 1, r, k - 1, 1) + d(l, r);
            if (v1 <= t[l]) bst = min(bst, v1);
            int v2 = rec(l + 1, r, k - 1, 0) + d(l, l + 1);
            if (v2 <= t[l]) bst = min(bst, v2);
        }
    }
    if (s && r > 0) {
        bst = min(bst, rec(l, r - 1, k, 0) + d(l, r));
        bst = min(bst, rec(l, r - 1, k, 1) + d(r - 1, r));
        if (k) {
            int v1 = rec(l, r - 1, k - 1, 0) + d(l, r);
            if (v1 <= t[r]) bst = min(bst, v1);
            int v2 = rec(l, r - 1, k - 1, 1) + d(r - 1, r);
            if (v2 <= t[r]) bst = min(bst, v2);
        }
    }
    return dp[l][r][k][s] = bst;
}

int32_t main() {
    boost();

    cin >> n >> L;
    for (int i = 1; i <= n; i++) cin >> x[i];
    for (int i = 1; i <= n; i++) cin >> t[i];
    memset(dp, -1, sizeof(dp));
    dp[0][0][0][0] = dp[0][0][0][1] = dp[n + 1][0][0][0] = dp[n + 1][0][0][1] = 0;
    for (int l = 0; l <= n; l++) {
        int r = l - 1;
        if (r < 0) r = n;
        for (int k = 1; k <= n; k++) if (min(rec(l, r, k, 0),  rec(l, r, k, 1)) < 1e5) ans = max(ans, k);
    }
    printf("%lld\n", ans);

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 135072 KB Output is correct
2 Correct 48 ms 135168 KB Output is correct
3 Correct 49 ms 135156 KB Output is correct
4 Correct 50 ms 135128 KB Output is correct
5 Correct 48 ms 135116 KB Output is correct
6 Correct 50 ms 135136 KB Output is correct
7 Correct 49 ms 135144 KB Output is correct
8 Correct 49 ms 135116 KB Output is correct
9 Correct 48 ms 135152 KB Output is correct
10 Correct 48 ms 135104 KB Output is correct
11 Correct 49 ms 135124 KB Output is correct
12 Correct 52 ms 135116 KB Output is correct
13 Correct 50 ms 135116 KB Output is correct
14 Correct 50 ms 135140 KB Output is correct
15 Correct 49 ms 135152 KB Output is correct
16 Correct 49 ms 135084 KB Output is correct
17 Correct 49 ms 135148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 135072 KB Output is correct
2 Correct 48 ms 135168 KB Output is correct
3 Correct 49 ms 135156 KB Output is correct
4 Correct 50 ms 135128 KB Output is correct
5 Correct 48 ms 135116 KB Output is correct
6 Correct 50 ms 135136 KB Output is correct
7 Correct 49 ms 135144 KB Output is correct
8 Correct 49 ms 135116 KB Output is correct
9 Correct 48 ms 135152 KB Output is correct
10 Correct 48 ms 135104 KB Output is correct
11 Correct 49 ms 135124 KB Output is correct
12 Correct 52 ms 135116 KB Output is correct
13 Correct 50 ms 135116 KB Output is correct
14 Correct 50 ms 135140 KB Output is correct
15 Correct 49 ms 135152 KB Output is correct
16 Correct 49 ms 135084 KB Output is correct
17 Correct 49 ms 135148 KB Output is correct
18 Incorrect 52 ms 135116 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 135072 KB Output is correct
2 Correct 48 ms 135168 KB Output is correct
3 Correct 49 ms 135156 KB Output is correct
4 Correct 50 ms 135128 KB Output is correct
5 Correct 48 ms 135116 KB Output is correct
6 Correct 50 ms 135136 KB Output is correct
7 Correct 49 ms 135144 KB Output is correct
8 Correct 49 ms 135116 KB Output is correct
9 Correct 48 ms 135152 KB Output is correct
10 Correct 48 ms 135104 KB Output is correct
11 Correct 49 ms 135124 KB Output is correct
12 Correct 52 ms 135116 KB Output is correct
13 Correct 50 ms 135116 KB Output is correct
14 Correct 50 ms 135140 KB Output is correct
15 Correct 49 ms 135152 KB Output is correct
16 Correct 49 ms 135084 KB Output is correct
17 Correct 49 ms 135148 KB Output is correct
18 Correct 505 ms 135192 KB Output is correct
19 Correct 258 ms 135188 KB Output is correct
20 Correct 131 ms 135096 KB Output is correct
21 Correct 240 ms 135304 KB Output is correct
22 Correct 333 ms 135188 KB Output is correct
23 Correct 113 ms 135116 KB Output is correct
24 Correct 95 ms 135140 KB Output is correct
25 Correct 108 ms 135180 KB Output is correct
26 Correct 64 ms 135116 KB Output is correct
27 Correct 115 ms 135124 KB Output is correct
28 Correct 89 ms 135172 KB Output is correct
29 Correct 116 ms 135068 KB Output is correct
30 Correct 96 ms 135160 KB Output is correct
31 Correct 110 ms 135072 KB Output is correct
32 Correct 76 ms 135104 KB Output is correct
33 Correct 112 ms 135196 KB Output is correct
34 Correct 63 ms 135192 KB Output is correct
35 Correct 107 ms 135112 KB Output is correct
36 Correct 68 ms 135060 KB Output is correct
37 Correct 116 ms 135120 KB Output is correct
38 Correct 80 ms 135076 KB Output is correct
39 Correct 119 ms 135180 KB Output is correct
40 Correct 79 ms 135172 KB Output is correct
41 Correct 658 ms 135192 KB Output is correct
42 Correct 378 ms 135196 KB Output is correct
43 Correct 664 ms 135192 KB Output is correct
44 Correct 375 ms 135192 KB Output is correct
45 Correct 648 ms 135192 KB Output is correct
46 Correct 393 ms 135316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 135072 KB Output is correct
2 Correct 48 ms 135168 KB Output is correct
3 Correct 49 ms 135156 KB Output is correct
4 Correct 50 ms 135128 KB Output is correct
5 Correct 48 ms 135116 KB Output is correct
6 Correct 50 ms 135136 KB Output is correct
7 Correct 49 ms 135144 KB Output is correct
8 Correct 49 ms 135116 KB Output is correct
9 Correct 48 ms 135152 KB Output is correct
10 Correct 48 ms 135104 KB Output is correct
11 Correct 49 ms 135124 KB Output is correct
12 Correct 52 ms 135116 KB Output is correct
13 Correct 50 ms 135116 KB Output is correct
14 Correct 50 ms 135140 KB Output is correct
15 Correct 49 ms 135152 KB Output is correct
16 Correct 49 ms 135084 KB Output is correct
17 Correct 49 ms 135148 KB Output is correct
18 Incorrect 52 ms 135116 KB Output isn't correct
19 Halted 0 ms 0 KB -