답안 #890582

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890582 2023-12-21T13:53:44 Z ParsaS Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
46 ms 135512 KB
// In the name of God
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
const int N = 200 + 5;
int n, L, X[N], T[N];
ll dp[N][N][N][2];

void solve() {
	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, 63, sizeof dp);
	X[n + 1] = L;
	dp[0][n + 1][0][0] = dp[0][n + 1][0][1] = 0;
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = n + 1; j > i; j--) {
			for (int k = 0; k <= n; k++) {
				if (i == 0 && j == n + 1 && k == 0)
					continue;
				ll x = 1e17;
				if (i) {
					x = dp[i - 1][j][k][0] + X[i] - X[i - 1];
					if (dp[i - 1][j][k - 1][0] + X[i] - X[i - 1] <= T[i]) {
						x = min(x, dp[i - 1][j][k - 1][0] + X[i] - X[i - 1]);
					}
					x = min(x, dp[i - 1][j][k][1] + X[i] + L - X[j]);
					if (dp[i - 1][j][k - 1][1] + X[i] + L - X[j] <= T[i]) {
						x = min(x, dp[i - 1][j][k - 1][1] + X[i] + L - X[j]);
					}
				}
				if (x < 1e17)
					ans = max(ans, k);
				dp[i][j][k][0] = x;
				x = 1e17;
				if (j < n + 1) {
					x = dp[i][j + 1][k][1] + X[j + 1] - X[j];
					if (dp[i][j + 1][k - 1][1] + X[j + 1] - X[j] <= T[j])
						x = min(x, dp[i][j + 1][k - 1][1] + X[j + 1] - X[j]);
					x = min(x, dp[i][j + 1][k][0] + X[i] + L - X[j]);
					if (dp[i][j + 1][k - 1][0] + X[i] + L - X[j] <= T[j])
						x = min(x, dp[i][j + 1][k - 1][0] + X[i] + L - X[j]);
				}
				if (x < 1e17)
					ans = max(ans, k);
				dp[i][j][k][1] = x;
			}
		}
	}
	cout << ans << endl;
}	

int32_t main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int tc = 1; // cin >> tc;
	while (tc--) {
		solve();
	}

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 135168 KB Output is correct
2 Correct 16 ms 135260 KB Output is correct
3 Correct 15 ms 135256 KB Output is correct
4 Correct 16 ms 135256 KB Output is correct
5 Correct 16 ms 135260 KB Output is correct
6 Correct 17 ms 135260 KB Output is correct
7 Correct 16 ms 135272 KB Output is correct
8 Correct 18 ms 135260 KB Output is correct
9 Correct 16 ms 135260 KB Output is correct
10 Correct 16 ms 135168 KB Output is correct
11 Correct 16 ms 135260 KB Output is correct
12 Correct 16 ms 135260 KB Output is correct
13 Correct 17 ms 135256 KB Output is correct
14 Correct 16 ms 135260 KB Output is correct
15 Correct 16 ms 135120 KB Output is correct
16 Correct 16 ms 135176 KB Output is correct
17 Correct 16 ms 135260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 135168 KB Output is correct
2 Correct 16 ms 135260 KB Output is correct
3 Correct 15 ms 135256 KB Output is correct
4 Correct 16 ms 135256 KB Output is correct
5 Correct 16 ms 135260 KB Output is correct
6 Correct 17 ms 135260 KB Output is correct
7 Correct 16 ms 135272 KB Output is correct
8 Correct 18 ms 135260 KB Output is correct
9 Correct 16 ms 135260 KB Output is correct
10 Correct 16 ms 135168 KB Output is correct
11 Correct 16 ms 135260 KB Output is correct
12 Correct 16 ms 135260 KB Output is correct
13 Correct 17 ms 135256 KB Output is correct
14 Correct 16 ms 135260 KB Output is correct
15 Correct 16 ms 135120 KB Output is correct
16 Correct 16 ms 135176 KB Output is correct
17 Correct 16 ms 135260 KB Output is correct
18 Correct 16 ms 135256 KB Output is correct
19 Correct 16 ms 135260 KB Output is correct
20 Correct 17 ms 135260 KB Output is correct
21 Correct 16 ms 135260 KB Output is correct
22 Correct 16 ms 135260 KB Output is correct
23 Correct 17 ms 135260 KB Output is correct
24 Correct 15 ms 135260 KB Output is correct
25 Correct 17 ms 135284 KB Output is correct
26 Correct 16 ms 135248 KB Output is correct
27 Correct 16 ms 135260 KB Output is correct
28 Correct 17 ms 135232 KB Output is correct
29 Correct 15 ms 135260 KB Output is correct
30 Correct 16 ms 135108 KB Output is correct
31 Correct 16 ms 135136 KB Output is correct
32 Correct 15 ms 135260 KB Output is correct
33 Correct 16 ms 135260 KB Output is correct
34 Correct 16 ms 135260 KB Output is correct
35 Correct 16 ms 135260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 135168 KB Output is correct
2 Correct 16 ms 135260 KB Output is correct
3 Correct 15 ms 135256 KB Output is correct
4 Correct 16 ms 135256 KB Output is correct
5 Correct 16 ms 135260 KB Output is correct
6 Correct 17 ms 135260 KB Output is correct
7 Correct 16 ms 135272 KB Output is correct
8 Correct 18 ms 135260 KB Output is correct
9 Correct 16 ms 135260 KB Output is correct
10 Correct 16 ms 135168 KB Output is correct
11 Correct 16 ms 135260 KB Output is correct
12 Correct 16 ms 135260 KB Output is correct
13 Correct 17 ms 135256 KB Output is correct
14 Correct 16 ms 135260 KB Output is correct
15 Correct 16 ms 135120 KB Output is correct
16 Correct 16 ms 135176 KB Output is correct
17 Correct 16 ms 135260 KB Output is correct
18 Correct 34 ms 135260 KB Output is correct
19 Correct 26 ms 135220 KB Output is correct
20 Correct 20 ms 135256 KB Output is correct
21 Correct 27 ms 135260 KB Output is correct
22 Correct 33 ms 135256 KB Output is correct
23 Correct 22 ms 135260 KB Output is correct
24 Correct 19 ms 135248 KB Output is correct
25 Correct 20 ms 135512 KB Output is correct
26 Correct 16 ms 135260 KB Output is correct
27 Correct 22 ms 135224 KB Output is correct
28 Correct 18 ms 135260 KB Output is correct
29 Correct 19 ms 135260 KB Output is correct
30 Correct 18 ms 135260 KB Output is correct
31 Correct 19 ms 135172 KB Output is correct
32 Correct 17 ms 135260 KB Output is correct
33 Correct 18 ms 135260 KB Output is correct
34 Correct 17 ms 135260 KB Output is correct
35 Correct 20 ms 135260 KB Output is correct
36 Correct 17 ms 135160 KB Output is correct
37 Correct 19 ms 135256 KB Output is correct
38 Correct 17 ms 135260 KB Output is correct
39 Correct 19 ms 135168 KB Output is correct
40 Correct 17 ms 135260 KB Output is correct
41 Correct 42 ms 135260 KB Output is correct
42 Correct 29 ms 135260 KB Output is correct
43 Correct 41 ms 135256 KB Output is correct
44 Correct 29 ms 135260 KB Output is correct
45 Correct 42 ms 135308 KB Output is correct
46 Correct 37 ms 135252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 135168 KB Output is correct
2 Correct 16 ms 135260 KB Output is correct
3 Correct 15 ms 135256 KB Output is correct
4 Correct 16 ms 135256 KB Output is correct
5 Correct 16 ms 135260 KB Output is correct
6 Correct 17 ms 135260 KB Output is correct
7 Correct 16 ms 135272 KB Output is correct
8 Correct 18 ms 135260 KB Output is correct
9 Correct 16 ms 135260 KB Output is correct
10 Correct 16 ms 135168 KB Output is correct
11 Correct 16 ms 135260 KB Output is correct
12 Correct 16 ms 135260 KB Output is correct
13 Correct 17 ms 135256 KB Output is correct
14 Correct 16 ms 135260 KB Output is correct
15 Correct 16 ms 135120 KB Output is correct
16 Correct 16 ms 135176 KB Output is correct
17 Correct 16 ms 135260 KB Output is correct
18 Correct 16 ms 135256 KB Output is correct
19 Correct 16 ms 135260 KB Output is correct
20 Correct 17 ms 135260 KB Output is correct
21 Correct 16 ms 135260 KB Output is correct
22 Correct 16 ms 135260 KB Output is correct
23 Correct 17 ms 135260 KB Output is correct
24 Correct 15 ms 135260 KB Output is correct
25 Correct 17 ms 135284 KB Output is correct
26 Correct 16 ms 135248 KB Output is correct
27 Correct 16 ms 135260 KB Output is correct
28 Correct 17 ms 135232 KB Output is correct
29 Correct 15 ms 135260 KB Output is correct
30 Correct 16 ms 135108 KB Output is correct
31 Correct 16 ms 135136 KB Output is correct
32 Correct 15 ms 135260 KB Output is correct
33 Correct 16 ms 135260 KB Output is correct
34 Correct 16 ms 135260 KB Output is correct
35 Correct 16 ms 135260 KB Output is correct
36 Correct 34 ms 135260 KB Output is correct
37 Correct 26 ms 135220 KB Output is correct
38 Correct 20 ms 135256 KB Output is correct
39 Correct 27 ms 135260 KB Output is correct
40 Correct 33 ms 135256 KB Output is correct
41 Correct 22 ms 135260 KB Output is correct
42 Correct 19 ms 135248 KB Output is correct
43 Correct 20 ms 135512 KB Output is correct
44 Correct 16 ms 135260 KB Output is correct
45 Correct 22 ms 135224 KB Output is correct
46 Correct 18 ms 135260 KB Output is correct
47 Correct 19 ms 135260 KB Output is correct
48 Correct 18 ms 135260 KB Output is correct
49 Correct 19 ms 135172 KB Output is correct
50 Correct 17 ms 135260 KB Output is correct
51 Correct 18 ms 135260 KB Output is correct
52 Correct 17 ms 135260 KB Output is correct
53 Correct 20 ms 135260 KB Output is correct
54 Correct 17 ms 135160 KB Output is correct
55 Correct 19 ms 135256 KB Output is correct
56 Correct 17 ms 135260 KB Output is correct
57 Correct 19 ms 135168 KB Output is correct
58 Correct 17 ms 135260 KB Output is correct
59 Correct 42 ms 135260 KB Output is correct
60 Correct 29 ms 135260 KB Output is correct
61 Correct 41 ms 135256 KB Output is correct
62 Correct 29 ms 135260 KB Output is correct
63 Correct 42 ms 135308 KB Output is correct
64 Correct 37 ms 135252 KB Output is correct
65 Correct 38 ms 135188 KB Output is correct
66 Correct 37 ms 135260 KB Output is correct
67 Correct 35 ms 135260 KB Output is correct
68 Correct 32 ms 135260 KB Output is correct
69 Correct 37 ms 135260 KB Output is correct
70 Correct 38 ms 135248 KB Output is correct
71 Correct 38 ms 135124 KB Output is correct
72 Correct 39 ms 135260 KB Output is correct
73 Correct 34 ms 135260 KB Output is correct
74 Correct 34 ms 135260 KB Output is correct
75 Correct 35 ms 135260 KB Output is correct
76 Correct 41 ms 135248 KB Output is correct
77 Correct 43 ms 135508 KB Output is correct
78 Correct 36 ms 135180 KB Output is correct
79 Correct 38 ms 135260 KB Output is correct
80 Correct 43 ms 135260 KB Output is correct
81 Correct 33 ms 135260 KB Output is correct
82 Correct 35 ms 135260 KB Output is correct
83 Correct 42 ms 135312 KB Output is correct
84 Correct 40 ms 135224 KB Output is correct
85 Correct 38 ms 135260 KB Output is correct
86 Correct 39 ms 135260 KB Output is correct
87 Correct 35 ms 135260 KB Output is correct
88 Correct 44 ms 135192 KB Output is correct
89 Correct 43 ms 135248 KB Output is correct
90 Correct 36 ms 135256 KB Output is correct
91 Correct 42 ms 135260 KB Output is correct
92 Correct 46 ms 135260 KB Output is correct
93 Correct 40 ms 135256 KB Output is correct