답안 #363890

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
363890 2021-02-07T12:53:19 Z wind_reaper Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
188 ms 129552 KB
#include <bits/stdc++.h>

using namespace std;

const int64_t INF = 1e16;

template<typename T> 
void smin(T &a, T b){
	a = min(a, b);
}
int32_t main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	
	int n; 
	int64_t l; 
	cin >> n >> l; 

	vector<int64_t> pos(n+2), t(n+2);

	for(int i = 1; i <= n; i++)
		cin >> pos[i];

	for(int i = 1; i <= n; i++)
		cin >> t[i];

	t[0] = 0;
	pos[0] = 0;
	pos[n+1] = l;
	t[n+1] = 0; 
	int64_t dp[n+2][n+2][2][n+2];
	for(int i = 0; i < n + 2; i++)
		for(int j = 0; j < n + 2; j++)
			for(int k = 0; k < n + 2; k++)
				dp[i][j][0][k] = dp[i][j][1][k] = INF; 

	dp[0][n+1][0][0] = dp[0][n+1][1][0] = 0;
	for(int i = 0; i <= n; i++){
		for(int j = n+1; j > i + 1; --j){
			for(int k = 0; k < n; k++){
				int64_t min_time = min(dp[i][j][0][k]+pos[i+1]-pos[i], dp[i][j][1][k]+l-pos[j]+pos[i+1]);
				smin(dp[i+1][j][0][k+(min_time<=t[i+1] ? 1 : 0)], min_time);
				min_time = min(dp[i][j][0][k]+l-pos[j-1]+pos[i], dp[i][j][1][k]+pos[j]-pos[j-1]);
				smin(dp[i][j-1][1][k+(min_time<=t[j-1] ? 1 : 0)], min_time);
			}
		}
	}

	int ans = 0; 
	for(int i = 0; i <= n+1; i++)
		for(int j = 0; j <= n+1; j++)
			for(int k = 0; k <= n+1; k++)
				for(int z = 0; z < 2; z++)
					if(dp[i][j][z][k] <= 1000000000){
						ans = max(ans, k);
					}

	cout << ans << '\n';
	return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 508 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 508 KB Output is correct
18 Correct 120 ms 93292 KB Output is correct
19 Correct 58 ms 44268 KB Output is correct
20 Correct 23 ms 17388 KB Output is correct
21 Correct 53 ms 40556 KB Output is correct
22 Correct 83 ms 59884 KB Output is correct
23 Correct 18 ms 13804 KB Output is correct
24 Correct 13 ms 9580 KB Output is correct
25 Correct 17 ms 13292 KB Output is correct
26 Correct 4 ms 3436 KB Output is correct
27 Correct 19 ms 14316 KB Output is correct
28 Correct 11 ms 8684 KB Output is correct
29 Correct 19 ms 14572 KB Output is correct
30 Correct 13 ms 10220 KB Output is correct
31 Correct 18 ms 13292 KB Output is correct
32 Correct 7 ms 5228 KB Output is correct
33 Correct 17 ms 13292 KB Output is correct
34 Correct 4 ms 3052 KB Output is correct
35 Correct 17 ms 12908 KB Output is correct
36 Correct 6 ms 4460 KB Output is correct
37 Correct 20 ms 14188 KB Output is correct
38 Correct 9 ms 5868 KB Output is correct
39 Correct 20 ms 15084 KB Output is correct
40 Correct 9 ms 6892 KB Output is correct
41 Correct 164 ms 127468 KB Output is correct
42 Correct 90 ms 70636 KB Output is correct
43 Correct 171 ms 127596 KB Output is correct
44 Correct 89 ms 69356 KB Output is correct
45 Correct 156 ms 127468 KB Output is correct
46 Correct 93 ms 70804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 508 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 120 ms 93292 KB Output is correct
37 Correct 58 ms 44268 KB Output is correct
38 Correct 23 ms 17388 KB Output is correct
39 Correct 53 ms 40556 KB Output is correct
40 Correct 83 ms 59884 KB Output is correct
41 Correct 18 ms 13804 KB Output is correct
42 Correct 13 ms 9580 KB Output is correct
43 Correct 17 ms 13292 KB Output is correct
44 Correct 4 ms 3436 KB Output is correct
45 Correct 19 ms 14316 KB Output is correct
46 Correct 11 ms 8684 KB Output is correct
47 Correct 19 ms 14572 KB Output is correct
48 Correct 13 ms 10220 KB Output is correct
49 Correct 18 ms 13292 KB Output is correct
50 Correct 7 ms 5228 KB Output is correct
51 Correct 17 ms 13292 KB Output is correct
52 Correct 4 ms 3052 KB Output is correct
53 Correct 17 ms 12908 KB Output is correct
54 Correct 6 ms 4460 KB Output is correct
55 Correct 20 ms 14188 KB Output is correct
56 Correct 9 ms 5868 KB Output is correct
57 Correct 20 ms 15084 KB Output is correct
58 Correct 9 ms 6892 KB Output is correct
59 Correct 164 ms 127468 KB Output is correct
60 Correct 90 ms 70636 KB Output is correct
61 Correct 171 ms 127596 KB Output is correct
62 Correct 89 ms 69356 KB Output is correct
63 Correct 156 ms 127468 KB Output is correct
64 Correct 93 ms 70804 KB Output is correct
65 Correct 138 ms 109420 KB Output is correct
66 Correct 141 ms 96364 KB Output is correct
67 Correct 117 ms 90220 KB Output is correct
68 Correct 104 ms 79980 KB Output is correct
69 Correct 137 ms 107756 KB Output is correct
70 Correct 134 ms 101100 KB Output is correct
71 Correct 138 ms 102892 KB Output is correct
72 Correct 127 ms 104300 KB Output is correct
73 Correct 146 ms 93164 KB Output is correct
74 Correct 113 ms 84296 KB Output is correct
75 Correct 126 ms 98028 KB Output is correct
76 Correct 155 ms 120044 KB Output is correct
77 Correct 154 ms 120044 KB Output is correct
78 Correct 110 ms 81388 KB Output is correct
79 Correct 116 ms 85740 KB Output is correct
80 Correct 149 ms 116460 KB Output is correct
81 Correct 114 ms 87276 KB Output is correct
82 Correct 137 ms 94700 KB Output is correct
83 Correct 164 ms 127468 KB Output is correct
84 Correct 131 ms 101228 KB Output is correct
85 Correct 166 ms 114796 KB Output is correct
86 Correct 149 ms 111084 KB Output is correct
87 Correct 126 ms 97900 KB Output is correct
88 Correct 188 ms 129388 KB Output is correct
89 Correct 167 ms 129552 KB Output is correct
90 Correct 128 ms 99436 KB Output is correct
91 Correct 165 ms 129388 KB Output is correct
92 Correct 167 ms 129516 KB Output is correct
93 Correct 162 ms 125548 KB Output is correct