//記得跳題
#include<iostream>
#include<array>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map>
#include<cstring>
#include<iomanip>
#include<bitset>
#include<tuple>
#define ll long long
#define LL __int128_t
#define DB double
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (ll)(2e9)
#define MOD (ll)(1e9+7)
#define F first
#define S second
#define endl "\n"
#define AC ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
template<class T> using PQ=priority_queue<T,vector<T>,less<T> >;
void file(){
freopen("/Users/liaoyunyang/Desktop/meta_in.txt","r",stdin);
freopen("/Users/liaoyunyang/Desktop/meta_out.txt","w",stdout);
}
/*int s[200005],seg[800005];
void build(int id,int l,int r){
if(l==r){
seg[id]=s[l]; return;
}
int mid=(l+r)>>1;
build(id*2,l,mid);
build(id*2+1,mid+1,r);
seg[id]=max(seg[id*2],seg[id*2+1]);
}
int ask(int id,int l,int r,int L,int R){
if(l>R||r<L) return 0;
if(L<=l&&r<=R) return seg[id];
int mid=(l+r)>>1;
return max(ask(id*2,l,mid,L,R),ask(id*2+1,mid+1,r,L,R));
}
*/
ll dp[205][205][2][205],x[205],y[205],t[205];
signed main(){
AC;
int n,l; cin>>n>>l;
FOR(i,1,n+1){
cin>>x[i]; y[n-i+1]=l-x[i];
}
FOR(i,1,n+1) cin>>t[i];
FOR(i,0,n+1)FOR(j,0,n+1)FOR(k,0,2)FOR(s,0,i+j+1) dp[i][j][k][s]=INF;
dp[0][0][0][0]=dp[0][0][1][0]=0;
int ans=0;
FOR(i,0,n+1)FOR(j,0,n+1){
if(i+j>n) break;
FOR(k,0,2)FOR(s,0,min(n,i+j)+1)if(dp[i][j][k][s]!=INF){
//cout<<"dp["<<i<<"]["<<j<<"]["<<k<<"]["<<s<<"]="<<dp[i][j][k][s]<<endl;
ans=max(ans,s);
if(k==0){
if(dp[i][j][k][s]+x[i+1]-x[i]<=t[i+1]){
dp[i+1][j][k][s+1]=min(dp[i+1][j][k][s+1],dp[i][j][k][s]+x[i+1]-x[i]);
}
else{
dp[i+1][j][k][s]=min(dp[i+1][j][k][s],dp[i][j][k][s]+x[i+1]-x[i]);
}
if(dp[i][j][k][s]+y[j+1]+x[i]<=t[n-j]){
dp[i][j+1][k^1][s+1]=min(dp[i][j+1][k^1][s+1],dp[i][j][k][s]+y[j+1]+x[i]);
}
else{
dp[i][j+1][k^1][s]=min(dp[i][j+1][k^1][s],dp[i][j][k][s]+y[j+1]+x[i]);
}
}
else{
if(dp[i][j][k][s]+x[i+1]+y[j]<=t[i+1]){
dp[i+1][j][k^1][s+1]=min(dp[i+1][j][k^1][s+1],dp[i][j][k][s]+x[i+1]+y[j]);
}
else{
dp[i+1][j][k^1][s]=min(dp[i+1][j][k^1][s],dp[i][j][k][s]+x[i+1]+y[j]);
}
if(dp[i][j][k][s]+y[j+1]-y[j]<=t[n-j]){
dp[i][j+1][k][s+1]=min(dp[i][j+1][k][s+1],dp[i][j][k][s]+y[j+1]-y[j]);
}
else{
dp[i][j+1][k][s]=min(dp[i][j+1][k][s],dp[i][j][k][s]+y[j+1]-y[j]);
}
}
}
}
cout<<ans<<endl;
}
/*
*/
Compilation message
ho_t3.cpp: In function 'void file()':
ho_t3.cpp:37:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | freopen("/Users/liaoyunyang/Desktop/meta_in.txt","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t3.cpp:38:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
38 | freopen("/Users/liaoyunyang/Desktop/meta_out.txt","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
852 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
708 KB |
Output is correct |
9 |
Correct |
1 ms |
852 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
852 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
852 KB |
Output is correct |
17 |
Correct |
1 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
852 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
708 KB |
Output is correct |
9 |
Correct |
1 ms |
852 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
852 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
852 KB |
Output is correct |
17 |
Correct |
1 ms |
852 KB |
Output is correct |
18 |
Correct |
1 ms |
1108 KB |
Output is correct |
19 |
Correct |
1 ms |
724 KB |
Output is correct |
20 |
Correct |
1 ms |
852 KB |
Output is correct |
21 |
Correct |
1 ms |
1108 KB |
Output is correct |
22 |
Correct |
1 ms |
596 KB |
Output is correct |
23 |
Correct |
1 ms |
1108 KB |
Output is correct |
24 |
Correct |
1 ms |
972 KB |
Output is correct |
25 |
Correct |
1 ms |
1108 KB |
Output is correct |
26 |
Correct |
1 ms |
1108 KB |
Output is correct |
27 |
Correct |
1 ms |
584 KB |
Output is correct |
28 |
Correct |
1 ms |
596 KB |
Output is correct |
29 |
Correct |
1 ms |
1096 KB |
Output is correct |
30 |
Correct |
1 ms |
1224 KB |
Output is correct |
31 |
Correct |
1 ms |
1108 KB |
Output is correct |
32 |
Correct |
1 ms |
980 KB |
Output is correct |
33 |
Correct |
1 ms |
1108 KB |
Output is correct |
34 |
Correct |
1 ms |
1108 KB |
Output is correct |
35 |
Correct |
1 ms |
1092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
852 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
708 KB |
Output is correct |
9 |
Correct |
1 ms |
852 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
852 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
852 KB |
Output is correct |
17 |
Correct |
1 ms |
852 KB |
Output is correct |
18 |
Correct |
52 ms |
105120 KB |
Output is correct |
19 |
Correct |
34 ms |
63864 KB |
Output is correct |
20 |
Correct |
16 ms |
34156 KB |
Output is correct |
21 |
Correct |
30 ms |
60248 KB |
Output is correct |
22 |
Correct |
47 ms |
78028 KB |
Output is correct |
23 |
Correct |
17 ms |
28996 KB |
Output is correct |
24 |
Correct |
11 ms |
22764 KB |
Output is correct |
25 |
Correct |
14 ms |
28372 KB |
Output is correct |
26 |
Correct |
5 ms |
10964 KB |
Output is correct |
27 |
Correct |
17 ms |
29652 KB |
Output is correct |
28 |
Correct |
11 ms |
21220 KB |
Output is correct |
29 |
Correct |
15 ms |
30292 KB |
Output is correct |
30 |
Correct |
15 ms |
23884 KB |
Output is correct |
31 |
Correct |
13 ms |
28372 KB |
Output is correct |
32 |
Correct |
7 ms |
14932 KB |
Output is correct |
33 |
Correct |
14 ms |
28480 KB |
Output is correct |
34 |
Correct |
5 ms |
10196 KB |
Output is correct |
35 |
Correct |
13 ms |
27988 KB |
Output is correct |
36 |
Correct |
8 ms |
13256 KB |
Output is correct |
37 |
Correct |
14 ms |
29652 KB |
Output is correct |
38 |
Correct |
9 ms |
16340 KB |
Output is correct |
39 |
Correct |
14 ms |
30932 KB |
Output is correct |
40 |
Correct |
8 ms |
18108 KB |
Output is correct |
41 |
Correct |
66 ms |
129612 KB |
Output is correct |
42 |
Correct |
44 ms |
87344 KB |
Output is correct |
43 |
Correct |
67 ms |
129524 KB |
Output is correct |
44 |
Correct |
40 ms |
86316 KB |
Output is correct |
45 |
Correct |
67 ms |
129600 KB |
Output is correct |
46 |
Correct |
48 ms |
87384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
852 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
708 KB |
Output is correct |
9 |
Correct |
1 ms |
852 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
852 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
852 KB |
Output is correct |
17 |
Correct |
1 ms |
852 KB |
Output is correct |
18 |
Correct |
1 ms |
1108 KB |
Output is correct |
19 |
Correct |
1 ms |
724 KB |
Output is correct |
20 |
Correct |
1 ms |
852 KB |
Output is correct |
21 |
Correct |
1 ms |
1108 KB |
Output is correct |
22 |
Correct |
1 ms |
596 KB |
Output is correct |
23 |
Correct |
1 ms |
1108 KB |
Output is correct |
24 |
Correct |
1 ms |
972 KB |
Output is correct |
25 |
Correct |
1 ms |
1108 KB |
Output is correct |
26 |
Correct |
1 ms |
1108 KB |
Output is correct |
27 |
Correct |
1 ms |
584 KB |
Output is correct |
28 |
Correct |
1 ms |
596 KB |
Output is correct |
29 |
Correct |
1 ms |
1096 KB |
Output is correct |
30 |
Correct |
1 ms |
1224 KB |
Output is correct |
31 |
Correct |
1 ms |
1108 KB |
Output is correct |
32 |
Correct |
1 ms |
980 KB |
Output is correct |
33 |
Correct |
1 ms |
1108 KB |
Output is correct |
34 |
Correct |
1 ms |
1108 KB |
Output is correct |
35 |
Correct |
1 ms |
1092 KB |
Output is correct |
36 |
Correct |
52 ms |
105120 KB |
Output is correct |
37 |
Correct |
34 ms |
63864 KB |
Output is correct |
38 |
Correct |
16 ms |
34156 KB |
Output is correct |
39 |
Correct |
30 ms |
60248 KB |
Output is correct |
40 |
Correct |
47 ms |
78028 KB |
Output is correct |
41 |
Correct |
17 ms |
28996 KB |
Output is correct |
42 |
Correct |
11 ms |
22764 KB |
Output is correct |
43 |
Correct |
14 ms |
28372 KB |
Output is correct |
44 |
Correct |
5 ms |
10964 KB |
Output is correct |
45 |
Correct |
17 ms |
29652 KB |
Output is correct |
46 |
Correct |
11 ms |
21220 KB |
Output is correct |
47 |
Correct |
15 ms |
30292 KB |
Output is correct |
48 |
Correct |
15 ms |
23884 KB |
Output is correct |
49 |
Correct |
13 ms |
28372 KB |
Output is correct |
50 |
Correct |
7 ms |
14932 KB |
Output is correct |
51 |
Correct |
14 ms |
28480 KB |
Output is correct |
52 |
Correct |
5 ms |
10196 KB |
Output is correct |
53 |
Correct |
13 ms |
27988 KB |
Output is correct |
54 |
Correct |
8 ms |
13256 KB |
Output is correct |
55 |
Correct |
14 ms |
29652 KB |
Output is correct |
56 |
Correct |
9 ms |
16340 KB |
Output is correct |
57 |
Correct |
14 ms |
30932 KB |
Output is correct |
58 |
Correct |
8 ms |
18108 KB |
Output is correct |
59 |
Correct |
66 ms |
129612 KB |
Output is correct |
60 |
Correct |
44 ms |
87344 KB |
Output is correct |
61 |
Correct |
67 ms |
129524 KB |
Output is correct |
62 |
Correct |
40 ms |
86316 KB |
Output is correct |
63 |
Correct |
67 ms |
129600 KB |
Output is correct |
64 |
Correct |
48 ms |
87384 KB |
Output is correct |
65 |
Correct |
59 ms |
117072 KB |
Output is correct |
66 |
Correct |
54 ms |
107380 KB |
Output is correct |
67 |
Correct |
61 ms |
102736 KB |
Output is correct |
68 |
Correct |
48 ms |
94904 KB |
Output is correct |
69 |
Correct |
59 ms |
115816 KB |
Output is correct |
70 |
Correct |
57 ms |
110920 KB |
Output is correct |
71 |
Correct |
57 ms |
112192 KB |
Output is correct |
72 |
Correct |
59 ms |
113420 KB |
Output is correct |
73 |
Correct |
61 ms |
105052 KB |
Output is correct |
74 |
Correct |
50 ms |
98284 KB |
Output is correct |
75 |
Correct |
54 ms |
108644 KB |
Output is correct |
76 |
Correct |
73 ms |
124528 KB |
Output is correct |
77 |
Correct |
63 ms |
124464 KB |
Output is correct |
78 |
Correct |
51 ms |
95956 KB |
Output is correct |
79 |
Correct |
51 ms |
99344 KB |
Output is correct |
80 |
Correct |
68 ms |
122028 KB |
Output is correct |
81 |
Correct |
51 ms |
100548 KB |
Output is correct |
82 |
Correct |
54 ms |
106272 KB |
Output is correct |
83 |
Correct |
68 ms |
129548 KB |
Output is correct |
84 |
Correct |
56 ms |
110924 KB |
Output is correct |
85 |
Correct |
64 ms |
120768 KB |
Output is correct |
86 |
Correct |
68 ms |
118304 KB |
Output is correct |
87 |
Correct |
56 ms |
108620 KB |
Output is correct |
88 |
Correct |
78 ms |
130912 KB |
Output is correct |
89 |
Correct |
68 ms |
130912 KB |
Output is correct |
90 |
Correct |
50 ms |
109744 KB |
Output is correct |
91 |
Correct |
70 ms |
130872 KB |
Output is correct |
92 |
Correct |
69 ms |
130824 KB |
Output is correct |
93 |
Correct |
66 ms |
128436 KB |
Output is correct |