#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 205,INF=1e12;
int n , L;
int x[N] , t[N];
int dp[N][N][N][2];
int solve(int l ,int r , int time , int pos){
if(l==r) return 0;
if(dp[l][r][time][pos]!=-1) return dp[l][r][time][pos];
if(pos){
return dp[l][r][time][pos]=max(
solve(l,r+1,time+(x[r+1]-x[r]),1)+(time+(x[r+1]-x[r])<=t[r+1]),
solve(l,r+1,time+(L-x[l])+x[r],0)+(time+(L-x[l])+x[r]<=t[l]));
}
else{
return dp[l][r][time][pos]=max(
solve(l-1,r,time+(x[l]-x[l-1]),0)+(time+(x[l]-x[l-1])<=t[l-1]),
solve(l-1,r,time+(L-x[l])+x[r],1)+(time+(L-x[l])+x[r]<=t[r]));
}
}
int32_t main()
{
//freopen("abc.in", "r", stdin);
cin >> n >> L;
memset(dp,-1,sizeof dp);
for(int i = 1 ; i <= n ; i ++) cin>>x[i];
for(int i = 1 ; i <= n ; i ++) cin>>t[i];
cout<<max(solve(n,1,L-x[n],0)+(L-x[n]<=t[n]),solve(n,1,x[1],1)+(x[1]<=t[1]));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
135116 KB |
Output is correct |
2 |
Correct |
50 ms |
135148 KB |
Output is correct |
3 |
Correct |
50 ms |
135140 KB |
Output is correct |
4 |
Correct |
50 ms |
135116 KB |
Output is correct |
5 |
Correct |
49 ms |
135048 KB |
Output is correct |
6 |
Correct |
50 ms |
135116 KB |
Output is correct |
7 |
Correct |
63 ms |
135152 KB |
Output is correct |
8 |
Correct |
61 ms |
135100 KB |
Output is correct |
9 |
Correct |
50 ms |
135048 KB |
Output is correct |
10 |
Correct |
50 ms |
135132 KB |
Output is correct |
11 |
Correct |
53 ms |
135072 KB |
Output is correct |
12 |
Correct |
58 ms |
135048 KB |
Output is correct |
13 |
Correct |
56 ms |
135156 KB |
Output is correct |
14 |
Correct |
55 ms |
135116 KB |
Output is correct |
15 |
Correct |
52 ms |
135136 KB |
Output is correct |
16 |
Correct |
55 ms |
135116 KB |
Output is correct |
17 |
Correct |
53 ms |
135136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
135116 KB |
Output is correct |
2 |
Correct |
50 ms |
135148 KB |
Output is correct |
3 |
Correct |
50 ms |
135140 KB |
Output is correct |
4 |
Correct |
50 ms |
135116 KB |
Output is correct |
5 |
Correct |
49 ms |
135048 KB |
Output is correct |
6 |
Correct |
50 ms |
135116 KB |
Output is correct |
7 |
Correct |
63 ms |
135152 KB |
Output is correct |
8 |
Correct |
61 ms |
135100 KB |
Output is correct |
9 |
Correct |
50 ms |
135048 KB |
Output is correct |
10 |
Correct |
50 ms |
135132 KB |
Output is correct |
11 |
Correct |
53 ms |
135072 KB |
Output is correct |
12 |
Correct |
58 ms |
135048 KB |
Output is correct |
13 |
Correct |
56 ms |
135156 KB |
Output is correct |
14 |
Correct |
55 ms |
135116 KB |
Output is correct |
15 |
Correct |
52 ms |
135136 KB |
Output is correct |
16 |
Correct |
55 ms |
135116 KB |
Output is correct |
17 |
Correct |
53 ms |
135136 KB |
Output is correct |
18 |
Runtime error |
188 ms |
273724 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
135116 KB |
Output is correct |
2 |
Correct |
50 ms |
135148 KB |
Output is correct |
3 |
Correct |
50 ms |
135140 KB |
Output is correct |
4 |
Correct |
50 ms |
135116 KB |
Output is correct |
5 |
Correct |
49 ms |
135048 KB |
Output is correct |
6 |
Correct |
50 ms |
135116 KB |
Output is correct |
7 |
Correct |
63 ms |
135152 KB |
Output is correct |
8 |
Correct |
61 ms |
135100 KB |
Output is correct |
9 |
Correct |
50 ms |
135048 KB |
Output is correct |
10 |
Correct |
50 ms |
135132 KB |
Output is correct |
11 |
Correct |
53 ms |
135072 KB |
Output is correct |
12 |
Correct |
58 ms |
135048 KB |
Output is correct |
13 |
Correct |
56 ms |
135156 KB |
Output is correct |
14 |
Correct |
55 ms |
135116 KB |
Output is correct |
15 |
Correct |
52 ms |
135136 KB |
Output is correct |
16 |
Correct |
55 ms |
135116 KB |
Output is correct |
17 |
Correct |
53 ms |
135136 KB |
Output is correct |
18 |
Correct |
187 ms |
135168 KB |
Output is correct |
19 |
Correct |
123 ms |
135168 KB |
Output is correct |
20 |
Correct |
91 ms |
135164 KB |
Output is correct |
21 |
Correct |
127 ms |
135168 KB |
Output is correct |
22 |
Correct |
146 ms |
135168 KB |
Output is correct |
23 |
Incorrect |
78 ms |
135116 KB |
Output isn't correct |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
135116 KB |
Output is correct |
2 |
Correct |
50 ms |
135148 KB |
Output is correct |
3 |
Correct |
50 ms |
135140 KB |
Output is correct |
4 |
Correct |
50 ms |
135116 KB |
Output is correct |
5 |
Correct |
49 ms |
135048 KB |
Output is correct |
6 |
Correct |
50 ms |
135116 KB |
Output is correct |
7 |
Correct |
63 ms |
135152 KB |
Output is correct |
8 |
Correct |
61 ms |
135100 KB |
Output is correct |
9 |
Correct |
50 ms |
135048 KB |
Output is correct |
10 |
Correct |
50 ms |
135132 KB |
Output is correct |
11 |
Correct |
53 ms |
135072 KB |
Output is correct |
12 |
Correct |
58 ms |
135048 KB |
Output is correct |
13 |
Correct |
56 ms |
135156 KB |
Output is correct |
14 |
Correct |
55 ms |
135116 KB |
Output is correct |
15 |
Correct |
52 ms |
135136 KB |
Output is correct |
16 |
Correct |
55 ms |
135116 KB |
Output is correct |
17 |
Correct |
53 ms |
135136 KB |
Output is correct |
18 |
Runtime error |
188 ms |
273724 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |