답안 #704002

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
704002 2023-03-01T10:14:35 Z KenIsGenius Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
197 ms 130880 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define int long long
using namespace std;

#ifdef LOCAL
#define WOSAOJI freopen("in.txt", "r", stdin);
#else 
#define WOSAOJI ios_base::sync_with_stdio(0), cin.tie(0);
#endif

#define chmax(a, b) (a) = (a) > (b) ? (a) : (b)
#define chmin(a, b) (a) = (a) < (b) ? (a) : (b)

int n, L, ans;
int x[205], t[205];
int dp[205][205][205][2];

void upd(int l, int r, int y, int dir) {
    int now = dp[l][r][y][dir];
    if (now == 1ll << 60) return;
    chmax(ans, y);
    int nxt = (l + n) % (n + 1);
    int now1;
    if (dir == 0) now1 = now + (x[l] - x[nxt] + L) % L;
    else now1 = now + (x[r] - x[nxt] + L) % L;
    if (nxt != r)
        chmin(dp[nxt][r][y + (now1 <= t[nxt])][0], now1);
    nxt = (r + 1) % (n + 1);
    if (dir == 0) now1 = now + (x[nxt] - x[l] + L) % L;
    else now1 = now + (x[nxt] - x[r] + L) % L;
    if (nxt != l)
        chmin(dp[l][nxt][y + (now1 <= t[nxt])][1], now1);
}

signed main() {
    WOSAOJI
    cin >> n >> L;
    for (int i = 1; i <= n; i++) cin >> x[i];
    for (int i = 1; i <= n; i++) cin >> t[i];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int l = 0; l <= n; l++) {
                for (int k = 0; k < 2; k++)
                    dp[i][j][l][k] = 1ll << 60;
            }
        }
    }
    dp[0][0][0][0] = dp[0][0][0][1] = 0;
    upd(0, 0, 0, 0); upd(0, 0, 0, 1);
    for (int len = 1; len <= n; len++) {
        for (int l = n + 1; l >= 0; l--) {
            int r = (l + len) % (n + 1);
            if (l + len <= n) break;
            for (int y = 0; y <= n; y++) {
                upd(l % (n + 1), r, y, 0);
                upd(l % (n + 1), r, y, 1);
            }
        }
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 708 KB Output is correct
9 Correct 1 ms 836 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 708 KB Output is correct
9 Correct 1 ms 836 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 840 KB Output is correct
18 Correct 1 ms 968 KB Output is correct
19 Correct 1 ms 720 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 2 ms 1108 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 964 KB Output is correct
26 Correct 1 ms 980 KB Output is correct
27 Correct 1 ms 584 KB Output is correct
28 Correct 1 ms 596 KB Output is correct
29 Correct 1 ms 1108 KB Output is correct
30 Correct 1 ms 1108 KB Output is correct
31 Correct 1 ms 972 KB Output is correct
32 Correct 1 ms 980 KB Output is correct
33 Correct 1 ms 1096 KB Output is correct
34 Correct 1 ms 1108 KB Output is correct
35 Correct 1 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 708 KB Output is correct
9 Correct 1 ms 836 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 840 KB Output is correct
18 Correct 124 ms 104880 KB Output is correct
19 Correct 65 ms 63688 KB Output is correct
20 Correct 28 ms 34004 KB Output is correct
21 Correct 59 ms 60128 KB Output is correct
22 Correct 85 ms 77900 KB Output is correct
23 Correct 28 ms 29012 KB Output is correct
24 Correct 16 ms 22580 KB Output is correct
25 Correct 25 ms 28232 KB Output is correct
26 Correct 7 ms 10824 KB Output is correct
27 Correct 27 ms 29524 KB Output is correct
28 Correct 14 ms 21076 KB Output is correct
29 Correct 26 ms 30164 KB Output is correct
30 Correct 16 ms 23736 KB Output is correct
31 Correct 24 ms 28244 KB Output is correct
32 Correct 11 ms 14804 KB Output is correct
33 Correct 23 ms 28244 KB Output is correct
34 Correct 6 ms 10068 KB Output is correct
35 Correct 17 ms 27764 KB Output is correct
36 Correct 9 ms 13232 KB Output is correct
37 Correct 19 ms 29540 KB Output is correct
38 Correct 11 ms 16212 KB Output is correct
39 Correct 21 ms 30688 KB Output is correct
40 Correct 12 ms 18104 KB Output is correct
41 Correct 168 ms 129356 KB Output is correct
42 Correct 63 ms 87120 KB Output is correct
43 Correct 191 ms 129468 KB Output is correct
44 Correct 59 ms 86176 KB Output is correct
45 Correct 172 ms 129356 KB Output is correct
46 Correct 59 ms 87124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 708 KB Output is correct
9 Correct 1 ms 836 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 840 KB Output is correct
18 Correct 1 ms 968 KB Output is correct
19 Correct 1 ms 720 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 2 ms 1108 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 964 KB Output is correct
26 Correct 1 ms 980 KB Output is correct
27 Correct 1 ms 584 KB Output is correct
28 Correct 1 ms 596 KB Output is correct
29 Correct 1 ms 1108 KB Output is correct
30 Correct 1 ms 1108 KB Output is correct
31 Correct 1 ms 972 KB Output is correct
32 Correct 1 ms 980 KB Output is correct
33 Correct 1 ms 1096 KB Output is correct
34 Correct 1 ms 1108 KB Output is correct
35 Correct 1 ms 1108 KB Output is correct
36 Correct 124 ms 104880 KB Output is correct
37 Correct 65 ms 63688 KB Output is correct
38 Correct 28 ms 34004 KB Output is correct
39 Correct 59 ms 60128 KB Output is correct
40 Correct 85 ms 77900 KB Output is correct
41 Correct 28 ms 29012 KB Output is correct
42 Correct 16 ms 22580 KB Output is correct
43 Correct 25 ms 28232 KB Output is correct
44 Correct 7 ms 10824 KB Output is correct
45 Correct 27 ms 29524 KB Output is correct
46 Correct 14 ms 21076 KB Output is correct
47 Correct 26 ms 30164 KB Output is correct
48 Correct 16 ms 23736 KB Output is correct
49 Correct 24 ms 28244 KB Output is correct
50 Correct 11 ms 14804 KB Output is correct
51 Correct 23 ms 28244 KB Output is correct
52 Correct 6 ms 10068 KB Output is correct
53 Correct 17 ms 27764 KB Output is correct
54 Correct 9 ms 13232 KB Output is correct
55 Correct 19 ms 29540 KB Output is correct
56 Correct 11 ms 16212 KB Output is correct
57 Correct 21 ms 30688 KB Output is correct
58 Correct 12 ms 18104 KB Output is correct
59 Correct 168 ms 129356 KB Output is correct
60 Correct 63 ms 87120 KB Output is correct
61 Correct 191 ms 129468 KB Output is correct
62 Correct 59 ms 86176 KB Output is correct
63 Correct 172 ms 129356 KB Output is correct
64 Correct 59 ms 87124 KB Output is correct
65 Correct 143 ms 116812 KB Output is correct
66 Correct 143 ms 107296 KB Output is correct
67 Correct 122 ms 102644 KB Output is correct
68 Correct 104 ms 94708 KB Output is correct
69 Correct 143 ms 115672 KB Output is correct
70 Correct 156 ms 110856 KB Output is correct
71 Correct 130 ms 112048 KB Output is correct
72 Correct 155 ms 113252 KB Output is correct
73 Correct 103 ms 104908 KB Output is correct
74 Correct 129 ms 98120 KB Output is correct
75 Correct 125 ms 108440 KB Output is correct
76 Correct 171 ms 124284 KB Output is correct
77 Correct 153 ms 124324 KB Output is correct
78 Correct 118 ms 95856 KB Output is correct
79 Correct 116 ms 99236 KB Output is correct
80 Correct 163 ms 121768 KB Output is correct
81 Correct 113 ms 100376 KB Output is correct
82 Correct 103 ms 106124 KB Output is correct
83 Correct 159 ms 129468 KB Output is correct
84 Correct 114 ms 110852 KB Output is correct
85 Correct 128 ms 120580 KB Output is correct
86 Correct 120 ms 118128 KB Output is correct
87 Correct 132 ms 108376 KB Output is correct
88 Correct 197 ms 130880 KB Output is correct
89 Correct 173 ms 130764 KB Output is correct
90 Correct 79 ms 109644 KB Output is correct
91 Correct 195 ms 130756 KB Output is correct
92 Correct 168 ms 130764 KB Output is correct
93 Correct 97 ms 128188 KB Output is correct