#include<bits/stdc++.h>
using namespace std;
const int N = 201;
int t[N], x[N], ans;
int dp[N][N][N][2];
void update(int l,int r,int cnt,int j,int time)
{
int cur = l;
if(j) cur = r;
if(t[cur] >= time) cnt++;
int &curr = dp[l][r][cnt][j];
if(curr == -1 || curr > time) curr = time;
ans = max(ans, cnt);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, la, i, j, k;
cin>>n>>la;
for(i = 1; i <= n; i++)
cin>>x[i];
for(i = 1; i <= n; i++)
cin>>t[i];
memset(dp, -1, sizeof(dp));
x[0] = 0;
update(1, n, 0, 0, x[1]);
update(1, n, 0, 1, la - x[n]);
for(i = 1; i <= n; i++)
for(j = 1; j <= i; j++)
for(k = 0; k <= i; k++)
{
int l = j;
int r = n - i + j;
if(l >= r) continue;
if(dp[l][r][k][0] != -1)
{
int time = dp[l][r][k][0];
update(l+1, r, k, 0, time + x[l+1] - x[l]);
update(l+1, r, k, 1, time + x[l] + la - x[r]);
}
if(dp[l][r][k][1] != -1)
{
int time = dp[l][r][k][1];
update(l, r-1, k, 1, time + x[r] - x[r-1]);
update(l, r-1, k, 0, time + la - x[r] + x[l]);
}
}
cout<<ans<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
63864 KB |
Output is correct |
2 |
Correct |
31 ms |
63864 KB |
Output is correct |
3 |
Correct |
31 ms |
63864 KB |
Output is correct |
4 |
Correct |
32 ms |
63864 KB |
Output is correct |
5 |
Correct |
32 ms |
63864 KB |
Output is correct |
6 |
Correct |
31 ms |
63864 KB |
Output is correct |
7 |
Correct |
32 ms |
63872 KB |
Output is correct |
8 |
Correct |
32 ms |
63864 KB |
Output is correct |
9 |
Correct |
32 ms |
63864 KB |
Output is correct |
10 |
Correct |
31 ms |
63868 KB |
Output is correct |
11 |
Correct |
31 ms |
63872 KB |
Output is correct |
12 |
Correct |
32 ms |
63872 KB |
Output is correct |
13 |
Correct |
35 ms |
63864 KB |
Output is correct |
14 |
Correct |
32 ms |
63872 KB |
Output is correct |
15 |
Correct |
32 ms |
63864 KB |
Output is correct |
16 |
Correct |
31 ms |
63872 KB |
Output is correct |
17 |
Correct |
33 ms |
63864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
63864 KB |
Output is correct |
2 |
Correct |
31 ms |
63864 KB |
Output is correct |
3 |
Correct |
31 ms |
63864 KB |
Output is correct |
4 |
Correct |
32 ms |
63864 KB |
Output is correct |
5 |
Correct |
32 ms |
63864 KB |
Output is correct |
6 |
Correct |
31 ms |
63864 KB |
Output is correct |
7 |
Correct |
32 ms |
63872 KB |
Output is correct |
8 |
Correct |
32 ms |
63864 KB |
Output is correct |
9 |
Correct |
32 ms |
63864 KB |
Output is correct |
10 |
Correct |
31 ms |
63868 KB |
Output is correct |
11 |
Correct |
31 ms |
63872 KB |
Output is correct |
12 |
Correct |
32 ms |
63872 KB |
Output is correct |
13 |
Correct |
35 ms |
63864 KB |
Output is correct |
14 |
Correct |
32 ms |
63872 KB |
Output is correct |
15 |
Correct |
32 ms |
63864 KB |
Output is correct |
16 |
Correct |
31 ms |
63872 KB |
Output is correct |
17 |
Correct |
33 ms |
63864 KB |
Output is correct |
18 |
Incorrect |
31 ms |
63872 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
63864 KB |
Output is correct |
2 |
Correct |
31 ms |
63864 KB |
Output is correct |
3 |
Correct |
31 ms |
63864 KB |
Output is correct |
4 |
Correct |
32 ms |
63864 KB |
Output is correct |
5 |
Correct |
32 ms |
63864 KB |
Output is correct |
6 |
Correct |
31 ms |
63864 KB |
Output is correct |
7 |
Correct |
32 ms |
63872 KB |
Output is correct |
8 |
Correct |
32 ms |
63864 KB |
Output is correct |
9 |
Correct |
32 ms |
63864 KB |
Output is correct |
10 |
Correct |
31 ms |
63868 KB |
Output is correct |
11 |
Correct |
31 ms |
63872 KB |
Output is correct |
12 |
Correct |
32 ms |
63872 KB |
Output is correct |
13 |
Correct |
35 ms |
63864 KB |
Output is correct |
14 |
Correct |
32 ms |
63872 KB |
Output is correct |
15 |
Correct |
32 ms |
63864 KB |
Output is correct |
16 |
Correct |
31 ms |
63872 KB |
Output is correct |
17 |
Correct |
33 ms |
63864 KB |
Output is correct |
18 |
Correct |
62 ms |
63900 KB |
Output is correct |
19 |
Correct |
47 ms |
63864 KB |
Output is correct |
20 |
Correct |
38 ms |
63992 KB |
Output is correct |
21 |
Correct |
45 ms |
63872 KB |
Output is correct |
22 |
Correct |
52 ms |
63872 KB |
Output is correct |
23 |
Correct |
38 ms |
63868 KB |
Output is correct |
24 |
Correct |
35 ms |
63940 KB |
Output is correct |
25 |
Correct |
37 ms |
63864 KB |
Output is correct |
26 |
Correct |
34 ms |
63872 KB |
Output is correct |
27 |
Correct |
38 ms |
63864 KB |
Output is correct |
28 |
Correct |
35 ms |
63872 KB |
Output is correct |
29 |
Correct |
38 ms |
63872 KB |
Output is correct |
30 |
Correct |
34 ms |
63876 KB |
Output is correct |
31 |
Correct |
39 ms |
63840 KB |
Output is correct |
32 |
Correct |
33 ms |
63872 KB |
Output is correct |
33 |
Correct |
37 ms |
63864 KB |
Output is correct |
34 |
Correct |
33 ms |
63868 KB |
Output is correct |
35 |
Correct |
34 ms |
63864 KB |
Output is correct |
36 |
Correct |
32 ms |
63872 KB |
Output is correct |
37 |
Correct |
35 ms |
63940 KB |
Output is correct |
38 |
Correct |
33 ms |
63864 KB |
Output is correct |
39 |
Correct |
35 ms |
63864 KB |
Output is correct |
40 |
Correct |
33 ms |
63872 KB |
Output is correct |
41 |
Correct |
77 ms |
63992 KB |
Output is correct |
42 |
Correct |
36 ms |
63864 KB |
Output is correct |
43 |
Correct |
85 ms |
63872 KB |
Output is correct |
44 |
Correct |
38 ms |
63872 KB |
Output is correct |
45 |
Correct |
78 ms |
63952 KB |
Output is correct |
46 |
Correct |
37 ms |
63864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
63864 KB |
Output is correct |
2 |
Correct |
31 ms |
63864 KB |
Output is correct |
3 |
Correct |
31 ms |
63864 KB |
Output is correct |
4 |
Correct |
32 ms |
63864 KB |
Output is correct |
5 |
Correct |
32 ms |
63864 KB |
Output is correct |
6 |
Correct |
31 ms |
63864 KB |
Output is correct |
7 |
Correct |
32 ms |
63872 KB |
Output is correct |
8 |
Correct |
32 ms |
63864 KB |
Output is correct |
9 |
Correct |
32 ms |
63864 KB |
Output is correct |
10 |
Correct |
31 ms |
63868 KB |
Output is correct |
11 |
Correct |
31 ms |
63872 KB |
Output is correct |
12 |
Correct |
32 ms |
63872 KB |
Output is correct |
13 |
Correct |
35 ms |
63864 KB |
Output is correct |
14 |
Correct |
32 ms |
63872 KB |
Output is correct |
15 |
Correct |
32 ms |
63864 KB |
Output is correct |
16 |
Correct |
31 ms |
63872 KB |
Output is correct |
17 |
Correct |
33 ms |
63864 KB |
Output is correct |
18 |
Incorrect |
31 ms |
63872 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |