답안 #1065811

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1065811 2024-08-19T11:57:36 Z phoenix Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
189 ms 141140 KB
#include <bits/stdc++.h>

using namespace std;

#define cerr if (false) cout
using ll = long long;

const int N = 220;
const ll INF = 1e18;

int n, L;
int x[N];
int t[N];

ll dp[N][N][N][2];

int main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    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 k = 0; k <= n; k++)
                dp[i][j][k][0] = INF,
                dp[i][j][k][1] = INF;
    
    dp[0][0][0][0] = 0;
    dp[0][0][0][1] = 0;
    for (int k = 0; k < n; k++) {
        for (int s = 0; s < n; s++) {
            for (int l = 0; l <= s; l++) {
                int r = (l + n + 1 - s) % (n + 1);
                cerr << l << ' ' << r << endl;
                ll time, k_new;
                time = dp[l][r][k][0] + x[l + 1] - x[l];
                k_new = k + (time <= t[l + 1]);
                dp[l + 1][r][k_new][0] = min(dp[l + 1][r][k_new][0], time);
                cerr << "one\n";

                time = dp[l][r][k][1] + x[l + 1] + (L - x[r]) % L;
                k_new = k + (time <= t[l + 1]);
                dp[l + 1][r][k_new][0] = min(dp[l + 1][r][k_new][0], time);
                cerr << "two\n";
                
                int r1 = (r + n) % (n + 1);
                
                time = dp[l][r][k][0] + x[l] + L - x[r1];
                k_new = k + (time <= t[r1]);
                dp[l][r1][k_new][1] = min(dp[l][r1][k_new][1], time);
                cerr << "three\n";

                time = dp[l][r][k][1] + (x[r] - x[r1] + L) % L;
                k_new = k + (time <= t[r1]);
                dp[l][r1][k_new][1] = min(dp[l][r1][k_new][1], time);
                cerr << "four\n";
            }
        }
    }

    for (int k = n; k >= 0; k--) {
        for (int i = 0; i <= n; i++) {
            if (dp[i][(i + 1) % (n + 1)][k][0] != INF) {
                cout << k;
                return 0;
            }   
            if (dp[i][(i + 1) % (n + 1)][k][1] != INF) {
                cout << k;
                return 0;
            }   
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 6748 KB Output is correct
17 Correct 1 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 6748 KB Output is correct
17 Correct 1 ms 8540 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 8680 KB Output is correct
20 Correct 1 ms 8540 KB Output is correct
21 Correct 1 ms 6748 KB Output is correct
22 Correct 1 ms 8688 KB Output is correct
23 Correct 1 ms 6840 KB Output is correct
24 Correct 1 ms 8796 KB Output is correct
25 Correct 1 ms 6748 KB Output is correct
26 Correct 1 ms 6748 KB Output is correct
27 Correct 1 ms 6492 KB Output is correct
28 Correct 1 ms 8540 KB Output is correct
29 Correct 1 ms 7004 KB Output is correct
30 Correct 1 ms 7004 KB Output is correct
31 Correct 1 ms 6748 KB Output is correct
32 Correct 1 ms 8796 KB Output is correct
33 Correct 1 ms 8792 KB Output is correct
34 Correct 1 ms 7004 KB Output is correct
35 Correct 1 ms 7004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 6748 KB Output is correct
17 Correct 1 ms 8540 KB Output is correct
18 Correct 131 ms 114076 KB Output is correct
19 Correct 69 ms 71376 KB Output is correct
20 Correct 30 ms 39768 KB Output is correct
21 Correct 61 ms 66652 KB Output is correct
22 Correct 96 ms 85328 KB Output is correct
23 Correct 23 ms 34392 KB Output is correct
24 Correct 17 ms 27996 KB Output is correct
25 Correct 22 ms 33812 KB Output is correct
26 Correct 7 ms 17756 KB Output is correct
27 Correct 24 ms 35232 KB Output is correct
28 Correct 15 ms 27740 KB Output is correct
29 Correct 25 ms 36956 KB Output is correct
30 Correct 18 ms 29016 KB Output is correct
31 Correct 22 ms 33884 KB Output is correct
32 Correct 10 ms 21744 KB Output is correct
33 Correct 23 ms 33880 KB Output is correct
34 Correct 7 ms 15448 KB Output is correct
35 Correct 22 ms 33340 KB Output is correct
36 Correct 8 ms 20060 KB Output is correct
37 Correct 23 ms 35236 KB Output is correct
38 Correct 12 ms 21596 KB Output is correct
39 Correct 26 ms 36240 KB Output is correct
40 Correct 14 ms 23388 KB Output is correct
41 Correct 173 ms 139256 KB Output is correct
42 Correct 106 ms 95056 KB Output is correct
43 Correct 178 ms 139448 KB Output is correct
44 Correct 98 ms 94044 KB Output is correct
45 Correct 174 ms 139344 KB Output is correct
46 Correct 100 ms 95580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 6748 KB Output is correct
17 Correct 1 ms 8540 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 8680 KB Output is correct
20 Correct 1 ms 8540 KB Output is correct
21 Correct 1 ms 6748 KB Output is correct
22 Correct 1 ms 8688 KB Output is correct
23 Correct 1 ms 6840 KB Output is correct
24 Correct 1 ms 8796 KB Output is correct
25 Correct 1 ms 6748 KB Output is correct
26 Correct 1 ms 6748 KB Output is correct
27 Correct 1 ms 6492 KB Output is correct
28 Correct 1 ms 8540 KB Output is correct
29 Correct 1 ms 7004 KB Output is correct
30 Correct 1 ms 7004 KB Output is correct
31 Correct 1 ms 6748 KB Output is correct
32 Correct 1 ms 8796 KB Output is correct
33 Correct 1 ms 8792 KB Output is correct
34 Correct 1 ms 7004 KB Output is correct
35 Correct 1 ms 7004 KB Output is correct
36 Correct 131 ms 114076 KB Output is correct
37 Correct 69 ms 71376 KB Output is correct
38 Correct 30 ms 39768 KB Output is correct
39 Correct 61 ms 66652 KB Output is correct
40 Correct 96 ms 85328 KB Output is correct
41 Correct 23 ms 34392 KB Output is correct
42 Correct 17 ms 27996 KB Output is correct
43 Correct 22 ms 33812 KB Output is correct
44 Correct 7 ms 17756 KB Output is correct
45 Correct 24 ms 35232 KB Output is correct
46 Correct 15 ms 27740 KB Output is correct
47 Correct 25 ms 36956 KB Output is correct
48 Correct 18 ms 29016 KB Output is correct
49 Correct 22 ms 33884 KB Output is correct
50 Correct 10 ms 21744 KB Output is correct
51 Correct 23 ms 33880 KB Output is correct
52 Correct 7 ms 15448 KB Output is correct
53 Correct 22 ms 33340 KB Output is correct
54 Correct 8 ms 20060 KB Output is correct
55 Correct 23 ms 35236 KB Output is correct
56 Correct 12 ms 21596 KB Output is correct
57 Correct 26 ms 36240 KB Output is correct
58 Correct 14 ms 23388 KB Output is correct
59 Correct 173 ms 139256 KB Output is correct
60 Correct 106 ms 95056 KB Output is correct
61 Correct 178 ms 139448 KB Output is correct
62 Correct 98 ms 94044 KB Output is correct
63 Correct 174 ms 139344 KB Output is correct
64 Correct 100 ms 95580 KB Output is correct
65 Correct 150 ms 126420 KB Output is correct
66 Correct 138 ms 116008 KB Output is correct
67 Correct 129 ms 111188 KB Output is correct
68 Correct 118 ms 102996 KB Output is correct
69 Correct 155 ms 125296 KB Output is correct
70 Correct 141 ms 119864 KB Output is correct
71 Correct 142 ms 121188 KB Output is correct
72 Correct 144 ms 122704 KB Output is correct
73 Correct 129 ms 114136 KB Output is correct
74 Correct 128 ms 106576 KB Output is correct
75 Correct 143 ms 117420 KB Output is correct
76 Correct 170 ms 133952 KB Output is correct
77 Correct 173 ms 133976 KB Output is correct
78 Correct 116 ms 104700 KB Output is correct
79 Correct 131 ms 107604 KB Output is correct
80 Correct 160 ms 131668 KB Output is correct
81 Correct 122 ms 108892 KB Output is correct
82 Correct 132 ms 115268 KB Output is correct
83 Correct 174 ms 139344 KB Output is correct
84 Correct 140 ms 120280 KB Output is correct
85 Correct 170 ms 130388 KB Output is correct
86 Correct 162 ms 127824 KB Output is correct
87 Correct 138 ms 117596 KB Output is correct
88 Correct 176 ms 140692 KB Output is correct
89 Correct 176 ms 140624 KB Output is correct
90 Correct 137 ms 118800 KB Output is correct
91 Correct 189 ms 141140 KB Output is correct
92 Correct 185 ms 141032 KB Output is correct
93 Correct 177 ms 138324 KB Output is correct