#include <bits/stdc++.h>
using namespace std;
const int maxn = 204;
int n, l, dp[maxn][maxn][maxn][2], X[maxn], T[maxn];
int main(){
memset(dp, INT_MAX, sizeof dp);
ios::sync_with_stdio(0), cin.tie(0);
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][0][1] = 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][k][0] = min(dp[i][j][k][0], dp[i-1][j][k][0] + X[i] - X[i-1]);
}
if(j != n){
dp[i][j][k][1] = min(dp[i][j][k][1], dp[i][j+1][k][1] + X[j+1] - X[j]);
}
if(k){
if(i && dp[i-1][j][k-1][0] + X[i] - X[i-1] <= T[i]){
dp[i][j][k][0] = min(dp[i][j][k][0], dp[i-1][j][k-1][0] + X[i] - X[i-1]);
}
if(j != n && dp[i][j+1][k-1][1] + X[j+1] - X[j] <= T[j]){
dp[i][j][k][1] = min(dp[i][j][k][1], dp[i][j+1][k-1][1] + X[j+1] - X[j]);
}
}
dp[i][j][k][0] = min(dp[i][j][k][0], dp[i][j][k][1] + l - X[j] + X[i]);
dp[i][j][k][1] = min(dp[i][j][k][1], dp[i][j][k][0] + l - X[j] + X[i]);
if(min(dp[i][j][k][0],dp[i][j][k][1]) < 10000000000)ans = max(ans,k);
}
}
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
66816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
66816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
66816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
66816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |