#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define int long long
const int maxn = 210;
const ll inf = 1e18+10;
ll n, L;
ll x[maxn], t[maxn];
signed main()
{
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>> n >> L;
for(int i = 1; i <= n; i++) cin>> x[i];
for(int i = 1; i <= n; i++) cin>> t[i];
ll ans = 0;
for(int l = 0; l <= n; l++)
for(int R = l+1; R <= n+1; R++)
{
int r = R;
int A = 0, tim = 0;
for(int i = 1; i <= l; i++)
if(tim + x[i] <= t[i])
A++;
ans = max(ans,A);
tim = 2*x[l];
for(int i = n; i >= r; i--)
if(tim + (L-x[i]) <= t[i])
A++;
ans = max(ans,A);
// cout<< l <<" "<< r <<" "<< A <<"\n";
tim = 0, A = 0;
for(int i = n; i >= r; i--)
if(tim + (L-x[i]) <= t[i])
A++;
ans = max(ans,A);
tim = 2*(L-x[r]);
if(r == n+1) tim = 0;
for(int i = 1; i <= l; i++)
if(tim + x[i] <= t[i])
A++;
ans = max(ans,A);
// cout<< l <<" "<< r <<" "<< A <<"\n";
}
cout<< ans;
}
/*
6 25
3 4 7 17 21 23
11 7 17 10 8 10
10 87
9 23 33 38 42 44 45 62 67 78
15 91 7 27 31 53 12 91 89 46
4 19
3 7 12 14
2 0 5 4
5 20
4 5 8 13 17
18 23 15 7 10
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |