답안 #313376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
313376 2020-10-15T22:39:12 Z sofapuden Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
121 ms 133368 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 204;

ll n,l, X[maxn], T[maxn], dp[maxn][maxn][2][maxn];

int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	memset(dp, 0x3f, sizeof dp);	
	cin >> n >> l;
	for(int i = 1; i <= n; ++i)cin >> X[i];
	X[n+1] = l;
	for(int i = 1; i <= n; ++i)cin >> T[i];
	++n;
	T[0] = -1;
	dp[0][n][0][0] = 0;
	dp[0][n][1][0] = 0;
	
	int ans = 0;
	
	for(int x = n-1; x >= 1; --x){
		for(int i = 0; i+x <= n; ++i){
			int j = i+x;
			for(int k = 0; k <= n; ++k){
				if(i){
					dp[i][j][0][k] = min(dp[i][j][0][k], dp[i-1][j][0][k] + X[i] - X[i-1]);
				}
				if(j != n){
					dp[i][j][1][k] = min(dp[i][j][1][k], dp[i][j+1][1][k] + X[j+1] - X[j]);
				}
				if(k){
					if(i && dp[i-1][j][0][k-1] + X[i] - X[i-1] <= T[i]){
						dp[i][j][0][k] = min(dp[i][j][0][k], dp[i-1][j][0][k-1] + X[i] - X[i-1]);
					}
					if(j != n && dp[i][j+1][1][k-1] + X[j+1] - X[j] <= T[j]){
						dp[i][j][1][k] = min(dp[i][j][1][k], dp[i][j+1][1][k-1] + X[j+1] - X[j]);
					}
				}
				dp[i][j][0][k] = min(dp[i][j][0][k], dp[i][j][1][k] + l - X[j] + X[i]);
				dp[i][j][1][k] = min(dp[i][j][1][k], dp[i][j][0][k] + l - X[j] + X[i]);
				if(min(dp[i][j][0][k],dp[i][j][1][k]) < 10000000000ll)ans = max(ans,k);
			}
		}
	}
					
	
	cout << ans << "\n";
			
			
}
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 133244 KB Output is correct
2 Correct 74 ms 133240 KB Output is correct
3 Correct 74 ms 133244 KB Output is correct
4 Correct 76 ms 133368 KB Output is correct
5 Correct 77 ms 133240 KB Output is correct
6 Correct 74 ms 133260 KB Output is correct
7 Correct 76 ms 133240 KB Output is correct
8 Correct 75 ms 133240 KB Output is correct
9 Correct 73 ms 133188 KB Output is correct
10 Correct 76 ms 133240 KB Output is correct
11 Correct 73 ms 133368 KB Output is correct
12 Correct 74 ms 133240 KB Output is correct
13 Correct 74 ms 133368 KB Output is correct
14 Correct 74 ms 133240 KB Output is correct
15 Correct 75 ms 133240 KB Output is correct
16 Correct 74 ms 133240 KB Output is correct
17 Correct 74 ms 133240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 133244 KB Output is correct
2 Correct 74 ms 133240 KB Output is correct
3 Correct 74 ms 133244 KB Output is correct
4 Correct 76 ms 133368 KB Output is correct
5 Correct 77 ms 133240 KB Output is correct
6 Correct 74 ms 133260 KB Output is correct
7 Correct 76 ms 133240 KB Output is correct
8 Correct 75 ms 133240 KB Output is correct
9 Correct 73 ms 133188 KB Output is correct
10 Correct 76 ms 133240 KB Output is correct
11 Correct 73 ms 133368 KB Output is correct
12 Correct 74 ms 133240 KB Output is correct
13 Correct 74 ms 133368 KB Output is correct
14 Correct 74 ms 133240 KB Output is correct
15 Correct 75 ms 133240 KB Output is correct
16 Correct 74 ms 133240 KB Output is correct
17 Correct 74 ms 133240 KB Output is correct
18 Correct 76 ms 133172 KB Output is correct
19 Correct 75 ms 133240 KB Output is correct
20 Correct 75 ms 133240 KB Output is correct
21 Correct 75 ms 133240 KB Output is correct
22 Correct 74 ms 133240 KB Output is correct
23 Correct 75 ms 133368 KB Output is correct
24 Correct 73 ms 133240 KB Output is correct
25 Correct 74 ms 133240 KB Output is correct
26 Correct 75 ms 133240 KB Output is correct
27 Correct 74 ms 133240 KB Output is correct
28 Correct 75 ms 133240 KB Output is correct
29 Correct 75 ms 133368 KB Output is correct
30 Correct 75 ms 133240 KB Output is correct
31 Correct 76 ms 133264 KB Output is correct
32 Correct 76 ms 133240 KB Output is correct
33 Correct 75 ms 133228 KB Output is correct
34 Correct 75 ms 133240 KB Output is correct
35 Correct 77 ms 133240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 133244 KB Output is correct
2 Correct 74 ms 133240 KB Output is correct
3 Correct 74 ms 133244 KB Output is correct
4 Correct 76 ms 133368 KB Output is correct
5 Correct 77 ms 133240 KB Output is correct
6 Correct 74 ms 133260 KB Output is correct
7 Correct 76 ms 133240 KB Output is correct
8 Correct 75 ms 133240 KB Output is correct
9 Correct 73 ms 133188 KB Output is correct
10 Correct 76 ms 133240 KB Output is correct
11 Correct 73 ms 133368 KB Output is correct
12 Correct 74 ms 133240 KB Output is correct
13 Correct 74 ms 133368 KB Output is correct
14 Correct 74 ms 133240 KB Output is correct
15 Correct 75 ms 133240 KB Output is correct
16 Correct 74 ms 133240 KB Output is correct
17 Correct 74 ms 133240 KB Output is correct
18 Correct 106 ms 133240 KB Output is correct
19 Correct 88 ms 133256 KB Output is correct
20 Correct 82 ms 133240 KB Output is correct
21 Correct 89 ms 133240 KB Output is correct
22 Correct 95 ms 133192 KB Output is correct
23 Correct 79 ms 133368 KB Output is correct
24 Correct 77 ms 133240 KB Output is correct
25 Correct 79 ms 133240 KB Output is correct
26 Correct 76 ms 133368 KB Output is correct
27 Correct 80 ms 133240 KB Output is correct
28 Correct 79 ms 133240 KB Output is correct
29 Correct 86 ms 133240 KB Output is correct
30 Correct 78 ms 133240 KB Output is correct
31 Correct 79 ms 133240 KB Output is correct
32 Correct 78 ms 133240 KB Output is correct
33 Correct 80 ms 133272 KB Output is correct
34 Correct 76 ms 133244 KB Output is correct
35 Correct 79 ms 133240 KB Output is correct
36 Correct 78 ms 133240 KB Output is correct
37 Correct 81 ms 133216 KB Output is correct
38 Correct 78 ms 133240 KB Output is correct
39 Correct 82 ms 133240 KB Output is correct
40 Correct 78 ms 133240 KB Output is correct
41 Correct 116 ms 133368 KB Output is correct
42 Correct 96 ms 133288 KB Output is correct
43 Correct 114 ms 133240 KB Output is correct
44 Correct 97 ms 133240 KB Output is correct
45 Correct 121 ms 133368 KB Output is correct
46 Correct 99 ms 133240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 133244 KB Output is correct
2 Correct 74 ms 133240 KB Output is correct
3 Correct 74 ms 133244 KB Output is correct
4 Correct 76 ms 133368 KB Output is correct
5 Correct 77 ms 133240 KB Output is correct
6 Correct 74 ms 133260 KB Output is correct
7 Correct 76 ms 133240 KB Output is correct
8 Correct 75 ms 133240 KB Output is correct
9 Correct 73 ms 133188 KB Output is correct
10 Correct 76 ms 133240 KB Output is correct
11 Correct 73 ms 133368 KB Output is correct
12 Correct 74 ms 133240 KB Output is correct
13 Correct 74 ms 133368 KB Output is correct
14 Correct 74 ms 133240 KB Output is correct
15 Correct 75 ms 133240 KB Output is correct
16 Correct 74 ms 133240 KB Output is correct
17 Correct 74 ms 133240 KB Output is correct
18 Correct 76 ms 133172 KB Output is correct
19 Correct 75 ms 133240 KB Output is correct
20 Correct 75 ms 133240 KB Output is correct
21 Correct 75 ms 133240 KB Output is correct
22 Correct 74 ms 133240 KB Output is correct
23 Correct 75 ms 133368 KB Output is correct
24 Correct 73 ms 133240 KB Output is correct
25 Correct 74 ms 133240 KB Output is correct
26 Correct 75 ms 133240 KB Output is correct
27 Correct 74 ms 133240 KB Output is correct
28 Correct 75 ms 133240 KB Output is correct
29 Correct 75 ms 133368 KB Output is correct
30 Correct 75 ms 133240 KB Output is correct
31 Correct 76 ms 133264 KB Output is correct
32 Correct 76 ms 133240 KB Output is correct
33 Correct 75 ms 133228 KB Output is correct
34 Correct 75 ms 133240 KB Output is correct
35 Correct 77 ms 133240 KB Output is correct
36 Correct 106 ms 133240 KB Output is correct
37 Correct 88 ms 133256 KB Output is correct
38 Correct 82 ms 133240 KB Output is correct
39 Correct 89 ms 133240 KB Output is correct
40 Correct 95 ms 133192 KB Output is correct
41 Correct 79 ms 133368 KB Output is correct
42 Correct 77 ms 133240 KB Output is correct
43 Correct 79 ms 133240 KB Output is correct
44 Correct 76 ms 133368 KB Output is correct
45 Correct 80 ms 133240 KB Output is correct
46 Correct 79 ms 133240 KB Output is correct
47 Correct 86 ms 133240 KB Output is correct
48 Correct 78 ms 133240 KB Output is correct
49 Correct 79 ms 133240 KB Output is correct
50 Correct 78 ms 133240 KB Output is correct
51 Correct 80 ms 133272 KB Output is correct
52 Correct 76 ms 133244 KB Output is correct
53 Correct 79 ms 133240 KB Output is correct
54 Correct 78 ms 133240 KB Output is correct
55 Correct 81 ms 133216 KB Output is correct
56 Correct 78 ms 133240 KB Output is correct
57 Correct 82 ms 133240 KB Output is correct
58 Correct 78 ms 133240 KB Output is correct
59 Correct 116 ms 133368 KB Output is correct
60 Correct 96 ms 133288 KB Output is correct
61 Correct 114 ms 133240 KB Output is correct
62 Correct 97 ms 133240 KB Output is correct
63 Correct 121 ms 133368 KB Output is correct
64 Correct 99 ms 133240 KB Output is correct
65 Correct 110 ms 133340 KB Output is correct
66 Correct 106 ms 133240 KB Output is correct
67 Correct 106 ms 133256 KB Output is correct
68 Correct 99 ms 133240 KB Output is correct
69 Correct 109 ms 133240 KB Output is correct
70 Correct 108 ms 133356 KB Output is correct
71 Correct 108 ms 133240 KB Output is correct
72 Correct 110 ms 133240 KB Output is correct
73 Correct 104 ms 133244 KB Output is correct
74 Correct 102 ms 133280 KB Output is correct
75 Correct 104 ms 133368 KB Output is correct
76 Correct 115 ms 133240 KB Output is correct
77 Correct 111 ms 133300 KB Output is correct
78 Correct 103 ms 133240 KB Output is correct
79 Correct 102 ms 133240 KB Output is correct
80 Correct 112 ms 133332 KB Output is correct
81 Correct 102 ms 133240 KB Output is correct
82 Correct 104 ms 133240 KB Output is correct
83 Correct 114 ms 133272 KB Output is correct
84 Correct 106 ms 133240 KB Output is correct
85 Correct 110 ms 133240 KB Output is correct
86 Correct 109 ms 133240 KB Output is correct
87 Correct 107 ms 133240 KB Output is correct
88 Correct 116 ms 133240 KB Output is correct
89 Correct 119 ms 133240 KB Output is correct
90 Correct 105 ms 133240 KB Output is correct
91 Correct 116 ms 133240 KB Output is correct
92 Correct 114 ms 133240 KB Output is correct
93 Correct 114 ms 133300 KB Output is correct