답안 #529057

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
529057 2022-02-22T04:28:15 Z rk42745417 Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
125 ms 139352 KB
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using ld = long double;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = ll(4e18) + ll(2e15);
const double EPS = 1e-9;
static int LamyIsCute = []() {
	EmiliaMyWife
	return 48763;
}();

const int N = 207;
ll dp[N][N][N][2];

signed main() {
	for(int i = 0; i < N; i++)
		for(int j = 0; j < N; j++)
			for(int k = 0; k < N; k++)
				for(int w = 0; w < 2; w++)
					dp[i][j][k][w] = LINF;

	int n, l;
	cin >> n >> l;
	vector<int> arr(n), ti(n);
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	for(int i = 0; i < n; i++)
		cin >> ti[i];

	dp[1][0][ti[0] >= arr[0]][0] = arr[0];
	dp[0][1][ti.back() >= l - arr.back()][1] = l - arr.back();

	for(int i = 0; i < n; i++) {
		for(int j = 0; j + i < n; j++) {
			for(int k = 0; k <= n; k++) {
				if(dp[i][j][k][0] != LINF) {
					ll cur = dp[i][j][k][0] + (arr[i] - arr[i - 1]);
					dp[i + 1][j][k + (cur <= ti[i])][0] = min(dp[i + 1][j][k + (cur <= ti[i])][0], cur);

					cur = dp[i][j][k][0] + arr[i - 1] + (l - arr[n - j - 1]);
					dp[i][j + 1][k + (cur <= ti[n - j - 1])][1] = min(dp[i][j + 1][k + (cur <= ti[n - j - 1])][1], cur);
				}
				if(dp[i][j][k][1] != LINF) {
					ll cur = dp[i][j][k][1] + (l - arr[n - j]) + arr[i];
					dp[i + 1][j][k + (cur <= ti[i])][0] = min(dp[i + 1][j][k + (cur <= ti[i])][0], cur);

					cur = dp[i][j][k][1] + (arr[n - j] - arr[n - j - 1]);
					dp[i][j + 1][k + (cur <= ti[n - j - 1])][1] = min(dp[i][j + 1][k + (cur <= ti[n - j - 1])][1], cur);
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < N; i++)
		for(int j = 0; j < N; j++)
			for(int k = 0; k < N; k++)
				for(int w = 0; w < 2; w++)
					if(dp[i][j][k][w] < LINF)
						ans = max(ans, k);
	cout << ans << '\n';

}
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 139156 KB Output is correct
2 Correct 69 ms 139188 KB Output is correct
3 Correct 69 ms 139104 KB Output is correct
4 Correct 76 ms 139140 KB Output is correct
5 Correct 68 ms 139084 KB Output is correct
6 Correct 65 ms 139084 KB Output is correct
7 Correct 64 ms 139080 KB Output is correct
8 Correct 69 ms 139204 KB Output is correct
9 Correct 83 ms 139060 KB Output is correct
10 Correct 67 ms 139156 KB Output is correct
11 Correct 64 ms 139124 KB Output is correct
12 Correct 70 ms 139068 KB Output is correct
13 Correct 64 ms 139076 KB Output is correct
14 Correct 65 ms 139084 KB Output is correct
15 Correct 76 ms 139116 KB Output is correct
16 Correct 87 ms 139148 KB Output is correct
17 Correct 64 ms 139116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 139156 KB Output is correct
2 Correct 69 ms 139188 KB Output is correct
3 Correct 69 ms 139104 KB Output is correct
4 Correct 76 ms 139140 KB Output is correct
5 Correct 68 ms 139084 KB Output is correct
6 Correct 65 ms 139084 KB Output is correct
7 Correct 64 ms 139080 KB Output is correct
8 Correct 69 ms 139204 KB Output is correct
9 Correct 83 ms 139060 KB Output is correct
10 Correct 67 ms 139156 KB Output is correct
11 Correct 64 ms 139124 KB Output is correct
12 Correct 70 ms 139068 KB Output is correct
13 Correct 64 ms 139076 KB Output is correct
14 Correct 65 ms 139084 KB Output is correct
15 Correct 76 ms 139116 KB Output is correct
16 Correct 87 ms 139148 KB Output is correct
17 Correct 64 ms 139116 KB Output is correct
18 Correct 64 ms 139048 KB Output is correct
19 Correct 66 ms 139144 KB Output is correct
20 Correct 67 ms 139160 KB Output is correct
21 Correct 65 ms 139104 KB Output is correct
22 Correct 74 ms 139096 KB Output is correct
23 Correct 77 ms 139140 KB Output is correct
24 Correct 68 ms 139056 KB Output is correct
25 Correct 68 ms 139076 KB Output is correct
26 Correct 63 ms 139052 KB Output is correct
27 Correct 67 ms 139180 KB Output is correct
28 Correct 71 ms 139084 KB Output is correct
29 Correct 84 ms 139116 KB Output is correct
30 Correct 68 ms 139124 KB Output is correct
31 Correct 66 ms 139168 KB Output is correct
32 Correct 65 ms 139112 KB Output is correct
33 Correct 65 ms 139140 KB Output is correct
34 Correct 69 ms 139112 KB Output is correct
35 Correct 88 ms 139052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 139156 KB Output is correct
2 Correct 69 ms 139188 KB Output is correct
3 Correct 69 ms 139104 KB Output is correct
4 Correct 76 ms 139140 KB Output is correct
5 Correct 68 ms 139084 KB Output is correct
6 Correct 65 ms 139084 KB Output is correct
7 Correct 64 ms 139080 KB Output is correct
8 Correct 69 ms 139204 KB Output is correct
9 Correct 83 ms 139060 KB Output is correct
10 Correct 67 ms 139156 KB Output is correct
11 Correct 64 ms 139124 KB Output is correct
12 Correct 70 ms 139068 KB Output is correct
13 Correct 64 ms 139076 KB Output is correct
14 Correct 65 ms 139084 KB Output is correct
15 Correct 76 ms 139116 KB Output is correct
16 Correct 87 ms 139148 KB Output is correct
17 Correct 64 ms 139116 KB Output is correct
18 Correct 92 ms 139156 KB Output is correct
19 Correct 85 ms 139156 KB Output is correct
20 Correct 71 ms 139156 KB Output is correct
21 Correct 78 ms 139152 KB Output is correct
22 Correct 86 ms 139160 KB Output is correct
23 Correct 84 ms 139180 KB Output is correct
24 Correct 77 ms 139156 KB Output is correct
25 Correct 71 ms 139112 KB Output is correct
26 Correct 67 ms 139164 KB Output is correct
27 Correct 72 ms 139156 KB Output is correct
28 Correct 67 ms 139104 KB Output is correct
29 Correct 75 ms 139156 KB Output is correct
30 Correct 79 ms 139100 KB Output is correct
31 Correct 71 ms 139036 KB Output is correct
32 Correct 67 ms 139072 KB Output is correct
33 Correct 71 ms 139144 KB Output is correct
34 Correct 66 ms 139152 KB Output is correct
35 Correct 86 ms 139112 KB Output is correct
36 Correct 76 ms 139116 KB Output is correct
37 Correct 68 ms 139084 KB Output is correct
38 Correct 74 ms 139156 KB Output is correct
39 Correct 68 ms 139052 KB Output is correct
40 Correct 67 ms 139152 KB Output is correct
41 Correct 110 ms 139096 KB Output is correct
42 Correct 94 ms 139104 KB Output is correct
43 Correct 116 ms 139160 KB Output is correct
44 Correct 68 ms 139032 KB Output is correct
45 Correct 105 ms 139076 KB Output is correct
46 Correct 81 ms 139156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 139156 KB Output is correct
2 Correct 69 ms 139188 KB Output is correct
3 Correct 69 ms 139104 KB Output is correct
4 Correct 76 ms 139140 KB Output is correct
5 Correct 68 ms 139084 KB Output is correct
6 Correct 65 ms 139084 KB Output is correct
7 Correct 64 ms 139080 KB Output is correct
8 Correct 69 ms 139204 KB Output is correct
9 Correct 83 ms 139060 KB Output is correct
10 Correct 67 ms 139156 KB Output is correct
11 Correct 64 ms 139124 KB Output is correct
12 Correct 70 ms 139068 KB Output is correct
13 Correct 64 ms 139076 KB Output is correct
14 Correct 65 ms 139084 KB Output is correct
15 Correct 76 ms 139116 KB Output is correct
16 Correct 87 ms 139148 KB Output is correct
17 Correct 64 ms 139116 KB Output is correct
18 Correct 64 ms 139048 KB Output is correct
19 Correct 66 ms 139144 KB Output is correct
20 Correct 67 ms 139160 KB Output is correct
21 Correct 65 ms 139104 KB Output is correct
22 Correct 74 ms 139096 KB Output is correct
23 Correct 77 ms 139140 KB Output is correct
24 Correct 68 ms 139056 KB Output is correct
25 Correct 68 ms 139076 KB Output is correct
26 Correct 63 ms 139052 KB Output is correct
27 Correct 67 ms 139180 KB Output is correct
28 Correct 71 ms 139084 KB Output is correct
29 Correct 84 ms 139116 KB Output is correct
30 Correct 68 ms 139124 KB Output is correct
31 Correct 66 ms 139168 KB Output is correct
32 Correct 65 ms 139112 KB Output is correct
33 Correct 65 ms 139140 KB Output is correct
34 Correct 69 ms 139112 KB Output is correct
35 Correct 88 ms 139052 KB Output is correct
36 Correct 92 ms 139156 KB Output is correct
37 Correct 85 ms 139156 KB Output is correct
38 Correct 71 ms 139156 KB Output is correct
39 Correct 78 ms 139152 KB Output is correct
40 Correct 86 ms 139160 KB Output is correct
41 Correct 84 ms 139180 KB Output is correct
42 Correct 77 ms 139156 KB Output is correct
43 Correct 71 ms 139112 KB Output is correct
44 Correct 67 ms 139164 KB Output is correct
45 Correct 72 ms 139156 KB Output is correct
46 Correct 67 ms 139104 KB Output is correct
47 Correct 75 ms 139156 KB Output is correct
48 Correct 79 ms 139100 KB Output is correct
49 Correct 71 ms 139036 KB Output is correct
50 Correct 67 ms 139072 KB Output is correct
51 Correct 71 ms 139144 KB Output is correct
52 Correct 66 ms 139152 KB Output is correct
53 Correct 86 ms 139112 KB Output is correct
54 Correct 76 ms 139116 KB Output is correct
55 Correct 68 ms 139084 KB Output is correct
56 Correct 74 ms 139156 KB Output is correct
57 Correct 68 ms 139052 KB Output is correct
58 Correct 67 ms 139152 KB Output is correct
59 Correct 110 ms 139096 KB Output is correct
60 Correct 94 ms 139104 KB Output is correct
61 Correct 116 ms 139160 KB Output is correct
62 Correct 68 ms 139032 KB Output is correct
63 Correct 105 ms 139076 KB Output is correct
64 Correct 81 ms 139156 KB Output is correct
65 Correct 97 ms 139160 KB Output is correct
66 Correct 97 ms 139108 KB Output is correct
67 Correct 103 ms 139276 KB Output is correct
68 Correct 101 ms 139160 KB Output is correct
69 Correct 115 ms 139352 KB Output is correct
70 Correct 106 ms 139084 KB Output is correct
71 Correct 98 ms 139160 KB Output is correct
72 Correct 113 ms 139156 KB Output is correct
73 Correct 93 ms 139156 KB Output is correct
74 Correct 108 ms 139156 KB Output is correct
75 Correct 94 ms 139168 KB Output is correct
76 Correct 113 ms 139164 KB Output is correct
77 Correct 103 ms 139104 KB Output is correct
78 Correct 102 ms 139052 KB Output is correct
79 Correct 98 ms 139172 KB Output is correct
80 Correct 111 ms 139160 KB Output is correct
81 Correct 100 ms 139132 KB Output is correct
82 Correct 88 ms 139076 KB Output is correct
83 Correct 108 ms 139160 KB Output is correct
84 Correct 92 ms 139156 KB Output is correct
85 Correct 95 ms 139148 KB Output is correct
86 Correct 91 ms 139076 KB Output is correct
87 Correct 98 ms 139116 KB Output is correct
88 Correct 120 ms 139164 KB Output is correct
89 Correct 125 ms 139156 KB Output is correct
90 Correct 90 ms 139096 KB Output is correct
91 Correct 122 ms 139144 KB Output is correct
92 Correct 114 ms 139160 KB Output is correct
93 Correct 74 ms 139064 KB Output is correct