답안 #285576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
285576 2020-08-29T09:21:41 Z kaplanbar Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
182 ms 135416 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 205;
int n, m;
ll x[2*N], t[2*N], dp[N][N][N][2];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for(int i = 0; i < n; i++) {
        cin >> t[i];
    }
    auto dist = [&](int now, int next) {
        int d = min(m - now, now);
        d += min(next, m - next);
        return min(abs(now - next), d);
    };
    x[n] = 0;
    t[n] = 1e9;
    for(int i = 1; i <= n; i++) {
        x[n + i] = x[i - 1];
        t[n + i] = t[i - 1];
    }
    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] = 1e18;
    dp[0][0][0][0] = dp[0][0][0][1] = 0;
    for(int l = 0; l <= n; l++) {
        for(int r = 0; l + r < n; r++) {
            if(l == n || r == n) continue;
            for(int cnt = 0; cnt <= l + r; cnt++) {
                for(int dir = 0; dir <= 1; dir++) {  
                    if(dp[l][r][cnt][dir] == 1e18) continue;
                    int now = dir ? x[n + r] : x[n - l];
                    int next = x[n + r + 1];
                    ll tim = t[n + r + 1];
                    ll tum = dp[l][r][cnt][dir] + dist(now, next);
                    dp[l][r + 1][cnt + (tum <= tim)][1] = min(dp[l][r + 1][cnt + (tum <= tim)][1], tum);
                    
                    next = x[n - l - 1];
                    tim = t[n - l - 1];
                    tum = dp[l][r][cnt][dir] + dist(now, next);
                    dp[l + 1][r][cnt + (tum <= tim)][0] = min(dp[l + 1][r][cnt + (tum <= tim)][0], tum);
                }
            }
        }
    }
    int ans = 0;
    for(int l = 0; l <= n; l++) for(int r = 0; r <= n; r++) for(int cnt = 0; cnt <= l + r; cnt++) {
        if(dp[l][r][cnt][0] < 1e18 || dp[l][r][cnt][1] < 1e18) ans = max(ans, cnt);
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 135160 KB Output is correct
2 Correct 90 ms 135204 KB Output is correct
3 Correct 77 ms 135288 KB Output is correct
4 Correct 76 ms 135160 KB Output is correct
5 Correct 76 ms 135160 KB Output is correct
6 Correct 77 ms 135160 KB Output is correct
7 Correct 77 ms 135160 KB Output is correct
8 Correct 79 ms 135288 KB Output is correct
9 Correct 80 ms 135160 KB Output is correct
10 Correct 76 ms 135256 KB Output is correct
11 Correct 80 ms 135160 KB Output is correct
12 Correct 79 ms 135180 KB Output is correct
13 Correct 79 ms 135160 KB Output is correct
14 Correct 76 ms 135192 KB Output is correct
15 Correct 77 ms 135160 KB Output is correct
16 Correct 79 ms 135200 KB Output is correct
17 Correct 77 ms 135160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 135160 KB Output is correct
2 Correct 90 ms 135204 KB Output is correct
3 Correct 77 ms 135288 KB Output is correct
4 Correct 76 ms 135160 KB Output is correct
5 Correct 76 ms 135160 KB Output is correct
6 Correct 77 ms 135160 KB Output is correct
7 Correct 77 ms 135160 KB Output is correct
8 Correct 79 ms 135288 KB Output is correct
9 Correct 80 ms 135160 KB Output is correct
10 Correct 76 ms 135256 KB Output is correct
11 Correct 80 ms 135160 KB Output is correct
12 Correct 79 ms 135180 KB Output is correct
13 Correct 79 ms 135160 KB Output is correct
14 Correct 76 ms 135192 KB Output is correct
15 Correct 77 ms 135160 KB Output is correct
16 Correct 79 ms 135200 KB Output is correct
17 Correct 77 ms 135160 KB Output is correct
18 Correct 78 ms 135160 KB Output is correct
19 Correct 77 ms 135160 KB Output is correct
20 Correct 77 ms 135160 KB Output is correct
21 Correct 79 ms 135160 KB Output is correct
22 Correct 77 ms 135288 KB Output is correct
23 Correct 77 ms 135160 KB Output is correct
24 Correct 78 ms 135160 KB Output is correct
25 Correct 77 ms 135164 KB Output is correct
26 Correct 77 ms 135160 KB Output is correct
27 Correct 89 ms 135160 KB Output is correct
28 Correct 77 ms 135160 KB Output is correct
29 Correct 77 ms 135244 KB Output is correct
30 Correct 77 ms 135292 KB Output is correct
31 Correct 79 ms 135160 KB Output is correct
32 Correct 78 ms 135160 KB Output is correct
33 Correct 78 ms 135160 KB Output is correct
34 Correct 77 ms 135160 KB Output is correct
35 Correct 77 ms 135160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 135160 KB Output is correct
2 Correct 90 ms 135204 KB Output is correct
3 Correct 77 ms 135288 KB Output is correct
4 Correct 76 ms 135160 KB Output is correct
5 Correct 76 ms 135160 KB Output is correct
6 Correct 77 ms 135160 KB Output is correct
7 Correct 77 ms 135160 KB Output is correct
8 Correct 79 ms 135288 KB Output is correct
9 Correct 80 ms 135160 KB Output is correct
10 Correct 76 ms 135256 KB Output is correct
11 Correct 80 ms 135160 KB Output is correct
12 Correct 79 ms 135180 KB Output is correct
13 Correct 79 ms 135160 KB Output is correct
14 Correct 76 ms 135192 KB Output is correct
15 Correct 77 ms 135160 KB Output is correct
16 Correct 79 ms 135200 KB Output is correct
17 Correct 77 ms 135160 KB Output is correct
18 Correct 136 ms 135288 KB Output is correct
19 Correct 120 ms 135288 KB Output is correct
20 Correct 91 ms 135288 KB Output is correct
21 Correct 107 ms 135160 KB Output is correct
22 Correct 119 ms 135160 KB Output is correct
23 Correct 91 ms 135336 KB Output is correct
24 Correct 82 ms 135288 KB Output is correct
25 Correct 88 ms 135160 KB Output is correct
26 Correct 78 ms 135164 KB Output is correct
27 Correct 102 ms 135152 KB Output is correct
28 Correct 82 ms 135160 KB Output is correct
29 Correct 88 ms 135260 KB Output is correct
30 Correct 84 ms 135160 KB Output is correct
31 Correct 87 ms 135160 KB Output is correct
32 Correct 83 ms 135160 KB Output is correct
33 Correct 87 ms 135152 KB Output is correct
34 Correct 78 ms 135160 KB Output is correct
35 Correct 83 ms 135160 KB Output is correct
36 Correct 80 ms 135160 KB Output is correct
37 Correct 87 ms 135160 KB Output is correct
38 Correct 82 ms 135160 KB Output is correct
39 Correct 85 ms 135160 KB Output is correct
40 Correct 82 ms 135160 KB Output is correct
41 Correct 167 ms 135160 KB Output is correct
42 Correct 99 ms 135160 KB Output is correct
43 Correct 169 ms 135160 KB Output is correct
44 Correct 98 ms 135160 KB Output is correct
45 Correct 171 ms 135288 KB Output is correct
46 Correct 97 ms 135160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 135160 KB Output is correct
2 Correct 90 ms 135204 KB Output is correct
3 Correct 77 ms 135288 KB Output is correct
4 Correct 76 ms 135160 KB Output is correct
5 Correct 76 ms 135160 KB Output is correct
6 Correct 77 ms 135160 KB Output is correct
7 Correct 77 ms 135160 KB Output is correct
8 Correct 79 ms 135288 KB Output is correct
9 Correct 80 ms 135160 KB Output is correct
10 Correct 76 ms 135256 KB Output is correct
11 Correct 80 ms 135160 KB Output is correct
12 Correct 79 ms 135180 KB Output is correct
13 Correct 79 ms 135160 KB Output is correct
14 Correct 76 ms 135192 KB Output is correct
15 Correct 77 ms 135160 KB Output is correct
16 Correct 79 ms 135200 KB Output is correct
17 Correct 77 ms 135160 KB Output is correct
18 Correct 78 ms 135160 KB Output is correct
19 Correct 77 ms 135160 KB Output is correct
20 Correct 77 ms 135160 KB Output is correct
21 Correct 79 ms 135160 KB Output is correct
22 Correct 77 ms 135288 KB Output is correct
23 Correct 77 ms 135160 KB Output is correct
24 Correct 78 ms 135160 KB Output is correct
25 Correct 77 ms 135164 KB Output is correct
26 Correct 77 ms 135160 KB Output is correct
27 Correct 89 ms 135160 KB Output is correct
28 Correct 77 ms 135160 KB Output is correct
29 Correct 77 ms 135244 KB Output is correct
30 Correct 77 ms 135292 KB Output is correct
31 Correct 79 ms 135160 KB Output is correct
32 Correct 78 ms 135160 KB Output is correct
33 Correct 78 ms 135160 KB Output is correct
34 Correct 77 ms 135160 KB Output is correct
35 Correct 77 ms 135160 KB Output is correct
36 Correct 136 ms 135288 KB Output is correct
37 Correct 120 ms 135288 KB Output is correct
38 Correct 91 ms 135288 KB Output is correct
39 Correct 107 ms 135160 KB Output is correct
40 Correct 119 ms 135160 KB Output is correct
41 Correct 91 ms 135336 KB Output is correct
42 Correct 82 ms 135288 KB Output is correct
43 Correct 88 ms 135160 KB Output is correct
44 Correct 78 ms 135164 KB Output is correct
45 Correct 102 ms 135152 KB Output is correct
46 Correct 82 ms 135160 KB Output is correct
47 Correct 88 ms 135260 KB Output is correct
48 Correct 84 ms 135160 KB Output is correct
49 Correct 87 ms 135160 KB Output is correct
50 Correct 83 ms 135160 KB Output is correct
51 Correct 87 ms 135152 KB Output is correct
52 Correct 78 ms 135160 KB Output is correct
53 Correct 83 ms 135160 KB Output is correct
54 Correct 80 ms 135160 KB Output is correct
55 Correct 87 ms 135160 KB Output is correct
56 Correct 82 ms 135160 KB Output is correct
57 Correct 85 ms 135160 KB Output is correct
58 Correct 82 ms 135160 KB Output is correct
59 Correct 167 ms 135160 KB Output is correct
60 Correct 99 ms 135160 KB Output is correct
61 Correct 169 ms 135160 KB Output is correct
62 Correct 98 ms 135160 KB Output is correct
63 Correct 171 ms 135288 KB Output is correct
64 Correct 97 ms 135160 KB Output is correct
65 Correct 152 ms 135272 KB Output is correct
66 Correct 163 ms 135248 KB Output is correct
67 Correct 137 ms 135160 KB Output is correct
68 Correct 129 ms 135160 KB Output is correct
69 Correct 161 ms 135160 KB Output is correct
70 Correct 152 ms 135160 KB Output is correct
71 Correct 143 ms 135160 KB Output is correct
72 Correct 179 ms 135232 KB Output is correct
73 Correct 123 ms 135160 KB Output is correct
74 Correct 142 ms 135416 KB Output is correct
75 Correct 154 ms 135160 KB Output is correct
76 Correct 170 ms 135268 KB Output is correct
77 Correct 153 ms 135164 KB Output is correct
78 Correct 138 ms 135160 KB Output is correct
79 Correct 139 ms 135160 KB Output is correct
80 Correct 169 ms 135252 KB Output is correct
81 Correct 134 ms 135160 KB Output is correct
82 Correct 131 ms 135164 KB Output is correct
83 Correct 159 ms 135160 KB Output is correct
84 Correct 132 ms 135160 KB Output is correct
85 Correct 137 ms 135160 KB Output is correct
86 Correct 152 ms 135164 KB Output is correct
87 Correct 148 ms 135160 KB Output is correct
88 Correct 182 ms 135268 KB Output is correct
89 Correct 169 ms 135264 KB Output is correct
90 Correct 103 ms 135160 KB Output is correct
91 Correct 182 ms 135288 KB Output is correct
92 Correct 163 ms 135160 KB Output is correct
93 Correct 111 ms 135160 KB Output is correct