#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define int long long
const int maxn = 5e5+10;
const ll inf = 1e18+10;
int n, L;
int x[maxn], t[maxn];
signed main()
{
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++;
tim = 2*x[l];
for(int i = n; i >= r; i--)
if(tim + (L-x[i]) <= t[i])
A++;
ans = max(ans,A);
A = 0, 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++;
tim = 0;
for(int i = n; i >= r; i--)
if(tim + (L-x[i]) <= t[i])
A++;
ans = max(ans,A);
}
cout<< ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |