#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 250,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]));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
244884 KB |
Output is correct |
2 |
Correct |
92 ms |
244836 KB |
Output is correct |
3 |
Correct |
90 ms |
244812 KB |
Output is correct |
4 |
Correct |
90 ms |
244840 KB |
Output is correct |
5 |
Correct |
90 ms |
244872 KB |
Output is correct |
6 |
Correct |
93 ms |
244828 KB |
Output is correct |
7 |
Correct |
87 ms |
244848 KB |
Output is correct |
8 |
Correct |
90 ms |
244812 KB |
Output is correct |
9 |
Correct |
90 ms |
244808 KB |
Output is correct |
10 |
Correct |
93 ms |
244860 KB |
Output is correct |
11 |
Correct |
92 ms |
244896 KB |
Output is correct |
12 |
Correct |
92 ms |
244908 KB |
Output is correct |
13 |
Correct |
90 ms |
244812 KB |
Output is correct |
14 |
Correct |
91 ms |
244812 KB |
Output is correct |
15 |
Correct |
97 ms |
244824 KB |
Output is correct |
16 |
Correct |
92 ms |
244832 KB |
Output is correct |
17 |
Correct |
88 ms |
244812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
244884 KB |
Output is correct |
2 |
Correct |
92 ms |
244836 KB |
Output is correct |
3 |
Correct |
90 ms |
244812 KB |
Output is correct |
4 |
Correct |
90 ms |
244840 KB |
Output is correct |
5 |
Correct |
90 ms |
244872 KB |
Output is correct |
6 |
Correct |
93 ms |
244828 KB |
Output is correct |
7 |
Correct |
87 ms |
244848 KB |
Output is correct |
8 |
Correct |
90 ms |
244812 KB |
Output is correct |
9 |
Correct |
90 ms |
244808 KB |
Output is correct |
10 |
Correct |
93 ms |
244860 KB |
Output is correct |
11 |
Correct |
92 ms |
244896 KB |
Output is correct |
12 |
Correct |
92 ms |
244908 KB |
Output is correct |
13 |
Correct |
90 ms |
244812 KB |
Output is correct |
14 |
Correct |
91 ms |
244812 KB |
Output is correct |
15 |
Correct |
97 ms |
244824 KB |
Output is correct |
16 |
Correct |
92 ms |
244832 KB |
Output is correct |
17 |
Correct |
88 ms |
244812 KB |
Output is correct |
18 |
Runtime error |
560 ms |
496272 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
244884 KB |
Output is correct |
2 |
Correct |
92 ms |
244836 KB |
Output is correct |
3 |
Correct |
90 ms |
244812 KB |
Output is correct |
4 |
Correct |
90 ms |
244840 KB |
Output is correct |
5 |
Correct |
90 ms |
244872 KB |
Output is correct |
6 |
Correct |
93 ms |
244828 KB |
Output is correct |
7 |
Correct |
87 ms |
244848 KB |
Output is correct |
8 |
Correct |
90 ms |
244812 KB |
Output is correct |
9 |
Correct |
90 ms |
244808 KB |
Output is correct |
10 |
Correct |
93 ms |
244860 KB |
Output is correct |
11 |
Correct |
92 ms |
244896 KB |
Output is correct |
12 |
Correct |
92 ms |
244908 KB |
Output is correct |
13 |
Correct |
90 ms |
244812 KB |
Output is correct |
14 |
Correct |
91 ms |
244812 KB |
Output is correct |
15 |
Correct |
97 ms |
244824 KB |
Output is correct |
16 |
Correct |
92 ms |
244832 KB |
Output is correct |
17 |
Correct |
88 ms |
244812 KB |
Output is correct |
18 |
Correct |
243 ms |
244980 KB |
Output is correct |
19 |
Correct |
160 ms |
244888 KB |
Output is correct |
20 |
Correct |
120 ms |
244812 KB |
Output is correct |
21 |
Incorrect |
142 ms |
244912 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
244884 KB |
Output is correct |
2 |
Correct |
92 ms |
244836 KB |
Output is correct |
3 |
Correct |
90 ms |
244812 KB |
Output is correct |
4 |
Correct |
90 ms |
244840 KB |
Output is correct |
5 |
Correct |
90 ms |
244872 KB |
Output is correct |
6 |
Correct |
93 ms |
244828 KB |
Output is correct |
7 |
Correct |
87 ms |
244848 KB |
Output is correct |
8 |
Correct |
90 ms |
244812 KB |
Output is correct |
9 |
Correct |
90 ms |
244808 KB |
Output is correct |
10 |
Correct |
93 ms |
244860 KB |
Output is correct |
11 |
Correct |
92 ms |
244896 KB |
Output is correct |
12 |
Correct |
92 ms |
244908 KB |
Output is correct |
13 |
Correct |
90 ms |
244812 KB |
Output is correct |
14 |
Correct |
91 ms |
244812 KB |
Output is correct |
15 |
Correct |
97 ms |
244824 KB |
Output is correct |
16 |
Correct |
92 ms |
244832 KB |
Output is correct |
17 |
Correct |
88 ms |
244812 KB |
Output is correct |
18 |
Runtime error |
560 ms |
496272 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |