#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair
typedef int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll maxn=2e2+10, maxm=1e3+10, lg=21, mod=1e9+7, inf=1e18;
ll n,L,X[maxn],T[maxn],dp[maxn][maxn][maxn][2],it,tt,ans=0;
void mst(ll &x,ll y){x=min(x,y);}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
memset(dp,69,sizeof(dp));
cin>>n>>L;
for(int i=1;i<=n;i++) cin>>X[i];
for(int i=1;i<=n;i++) cin>>T[i];
dp[0][0][0][0]=dp[0][0][1][0]=0;
for(int b=0;b<=n;b++)for(int f=0;b+f<=n;f++)for(int k=0;k<=b+f;k++){
it=dp[b][f][k][0];
if(it<mod){ ans=max(ans,k);
tt=it+X[f+1]-X[f];
mst(dp[b][f+1][k+(tt<=T[f+1])][0],tt);
tt=it+X[f]+L-X[n-b];
mst(dp[b+1][f][k+(tt<=T[n-b])][1],tt);
}
it=dp[b][f][k][1];
if(it<mod){ ans=max(ans,k);
tt=it+X[n-b+1]-X[n-b];
mst(dp[b+1][f][k+(tt<=T[n-b])][1],tt);
tt=it+L-X[n-b+1]+X[f+1];
mst(dp[b][f+1][k+(tt<=T[f+1])][0],tt);
}
}
cout<<ans;
return 0;
}
Compilation message
ho_t3.cpp:19:58: warning: overflow in implicit constant conversion [-Woverflow]
const ll maxn=2e2+10, maxm=1e3+10, lg=21, mod=1e9+7, inf=1e18;
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
72824 KB |
Output is correct |
2 |
Correct |
39 ms |
72812 KB |
Output is correct |
3 |
Correct |
38 ms |
72832 KB |
Output is correct |
4 |
Correct |
37 ms |
72868 KB |
Output is correct |
5 |
Correct |
38 ms |
72824 KB |
Output is correct |
6 |
Correct |
49 ms |
72824 KB |
Output is correct |
7 |
Correct |
39 ms |
72824 KB |
Output is correct |
8 |
Correct |
38 ms |
72824 KB |
Output is correct |
9 |
Correct |
38 ms |
72824 KB |
Output is correct |
10 |
Correct |
39 ms |
72824 KB |
Output is correct |
11 |
Correct |
37 ms |
72824 KB |
Output is correct |
12 |
Correct |
38 ms |
72832 KB |
Output is correct |
13 |
Correct |
38 ms |
72824 KB |
Output is correct |
14 |
Correct |
38 ms |
72832 KB |
Output is correct |
15 |
Correct |
38 ms |
72824 KB |
Output is correct |
16 |
Correct |
38 ms |
72824 KB |
Output is correct |
17 |
Correct |
38 ms |
72824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
72824 KB |
Output is correct |
2 |
Correct |
39 ms |
72812 KB |
Output is correct |
3 |
Correct |
38 ms |
72832 KB |
Output is correct |
4 |
Correct |
37 ms |
72868 KB |
Output is correct |
5 |
Correct |
38 ms |
72824 KB |
Output is correct |
6 |
Correct |
49 ms |
72824 KB |
Output is correct |
7 |
Correct |
39 ms |
72824 KB |
Output is correct |
8 |
Correct |
38 ms |
72824 KB |
Output is correct |
9 |
Correct |
38 ms |
72824 KB |
Output is correct |
10 |
Correct |
39 ms |
72824 KB |
Output is correct |
11 |
Correct |
37 ms |
72824 KB |
Output is correct |
12 |
Correct |
38 ms |
72832 KB |
Output is correct |
13 |
Correct |
38 ms |
72824 KB |
Output is correct |
14 |
Correct |
38 ms |
72832 KB |
Output is correct |
15 |
Correct |
38 ms |
72824 KB |
Output is correct |
16 |
Correct |
38 ms |
72824 KB |
Output is correct |
17 |
Correct |
38 ms |
72824 KB |
Output is correct |
18 |
Correct |
40 ms |
72832 KB |
Output is correct |
19 |
Correct |
39 ms |
72824 KB |
Output is correct |
20 |
Correct |
38 ms |
72824 KB |
Output is correct |
21 |
Correct |
37 ms |
72824 KB |
Output is correct |
22 |
Correct |
37 ms |
72824 KB |
Output is correct |
23 |
Correct |
40 ms |
72824 KB |
Output is correct |
24 |
Correct |
37 ms |
72832 KB |
Output is correct |
25 |
Correct |
38 ms |
72824 KB |
Output is correct |
26 |
Correct |
38 ms |
72824 KB |
Output is correct |
27 |
Correct |
37 ms |
72824 KB |
Output is correct |
28 |
Correct |
37 ms |
72824 KB |
Output is correct |
29 |
Correct |
38 ms |
72828 KB |
Output is correct |
30 |
Correct |
41 ms |
72848 KB |
Output is correct |
31 |
Correct |
37 ms |
72824 KB |
Output is correct |
32 |
Correct |
37 ms |
72824 KB |
Output is correct |
33 |
Correct |
38 ms |
72824 KB |
Output is correct |
34 |
Correct |
37 ms |
72824 KB |
Output is correct |
35 |
Correct |
37 ms |
72832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
72824 KB |
Output is correct |
2 |
Correct |
39 ms |
72812 KB |
Output is correct |
3 |
Correct |
38 ms |
72832 KB |
Output is correct |
4 |
Correct |
37 ms |
72868 KB |
Output is correct |
5 |
Correct |
38 ms |
72824 KB |
Output is correct |
6 |
Correct |
49 ms |
72824 KB |
Output is correct |
7 |
Correct |
39 ms |
72824 KB |
Output is correct |
8 |
Correct |
38 ms |
72824 KB |
Output is correct |
9 |
Correct |
38 ms |
72824 KB |
Output is correct |
10 |
Correct |
39 ms |
72824 KB |
Output is correct |
11 |
Correct |
37 ms |
72824 KB |
Output is correct |
12 |
Correct |
38 ms |
72832 KB |
Output is correct |
13 |
Correct |
38 ms |
72824 KB |
Output is correct |
14 |
Correct |
38 ms |
72832 KB |
Output is correct |
15 |
Correct |
38 ms |
72824 KB |
Output is correct |
16 |
Correct |
38 ms |
72824 KB |
Output is correct |
17 |
Correct |
38 ms |
72824 KB |
Output is correct |
18 |
Correct |
58 ms |
72952 KB |
Output is correct |
19 |
Correct |
48 ms |
72824 KB |
Output is correct |
20 |
Correct |
41 ms |
72824 KB |
Output is correct |
21 |
Correct |
48 ms |
72824 KB |
Output is correct |
22 |
Correct |
53 ms |
72824 KB |
Output is correct |
23 |
Correct |
42 ms |
72824 KB |
Output is correct |
24 |
Correct |
39 ms |
72828 KB |
Output is correct |
25 |
Correct |
42 ms |
72824 KB |
Output is correct |
26 |
Correct |
39 ms |
72824 KB |
Output is correct |
27 |
Correct |
43 ms |
72952 KB |
Output is correct |
28 |
Correct |
39 ms |
72824 KB |
Output is correct |
29 |
Correct |
43 ms |
72832 KB |
Output is correct |
30 |
Correct |
39 ms |
72824 KB |
Output is correct |
31 |
Correct |
41 ms |
72824 KB |
Output is correct |
32 |
Correct |
46 ms |
72952 KB |
Output is correct |
33 |
Correct |
41 ms |
72824 KB |
Output is correct |
34 |
Correct |
39 ms |
72824 KB |
Output is correct |
35 |
Correct |
40 ms |
72824 KB |
Output is correct |
36 |
Correct |
48 ms |
72828 KB |
Output is correct |
37 |
Correct |
41 ms |
72824 KB |
Output is correct |
38 |
Correct |
41 ms |
72824 KB |
Output is correct |
39 |
Correct |
41 ms |
72824 KB |
Output is correct |
40 |
Correct |
39 ms |
72824 KB |
Output is correct |
41 |
Correct |
69 ms |
72832 KB |
Output is correct |
42 |
Correct |
42 ms |
72824 KB |
Output is correct |
43 |
Correct |
71 ms |
72884 KB |
Output is correct |
44 |
Correct |
42 ms |
72960 KB |
Output is correct |
45 |
Correct |
70 ms |
72920 KB |
Output is correct |
46 |
Correct |
41 ms |
72824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
72824 KB |
Output is correct |
2 |
Correct |
39 ms |
72812 KB |
Output is correct |
3 |
Correct |
38 ms |
72832 KB |
Output is correct |
4 |
Correct |
37 ms |
72868 KB |
Output is correct |
5 |
Correct |
38 ms |
72824 KB |
Output is correct |
6 |
Correct |
49 ms |
72824 KB |
Output is correct |
7 |
Correct |
39 ms |
72824 KB |
Output is correct |
8 |
Correct |
38 ms |
72824 KB |
Output is correct |
9 |
Correct |
38 ms |
72824 KB |
Output is correct |
10 |
Correct |
39 ms |
72824 KB |
Output is correct |
11 |
Correct |
37 ms |
72824 KB |
Output is correct |
12 |
Correct |
38 ms |
72832 KB |
Output is correct |
13 |
Correct |
38 ms |
72824 KB |
Output is correct |
14 |
Correct |
38 ms |
72832 KB |
Output is correct |
15 |
Correct |
38 ms |
72824 KB |
Output is correct |
16 |
Correct |
38 ms |
72824 KB |
Output is correct |
17 |
Correct |
38 ms |
72824 KB |
Output is correct |
18 |
Correct |
40 ms |
72832 KB |
Output is correct |
19 |
Correct |
39 ms |
72824 KB |
Output is correct |
20 |
Correct |
38 ms |
72824 KB |
Output is correct |
21 |
Correct |
37 ms |
72824 KB |
Output is correct |
22 |
Correct |
37 ms |
72824 KB |
Output is correct |
23 |
Correct |
40 ms |
72824 KB |
Output is correct |
24 |
Correct |
37 ms |
72832 KB |
Output is correct |
25 |
Correct |
38 ms |
72824 KB |
Output is correct |
26 |
Correct |
38 ms |
72824 KB |
Output is correct |
27 |
Correct |
37 ms |
72824 KB |
Output is correct |
28 |
Correct |
37 ms |
72824 KB |
Output is correct |
29 |
Correct |
38 ms |
72828 KB |
Output is correct |
30 |
Correct |
41 ms |
72848 KB |
Output is correct |
31 |
Correct |
37 ms |
72824 KB |
Output is correct |
32 |
Correct |
37 ms |
72824 KB |
Output is correct |
33 |
Correct |
38 ms |
72824 KB |
Output is correct |
34 |
Correct |
37 ms |
72824 KB |
Output is correct |
35 |
Correct |
37 ms |
72832 KB |
Output is correct |
36 |
Correct |
58 ms |
72952 KB |
Output is correct |
37 |
Correct |
48 ms |
72824 KB |
Output is correct |
38 |
Correct |
41 ms |
72824 KB |
Output is correct |
39 |
Correct |
48 ms |
72824 KB |
Output is correct |
40 |
Correct |
53 ms |
72824 KB |
Output is correct |
41 |
Correct |
42 ms |
72824 KB |
Output is correct |
42 |
Correct |
39 ms |
72828 KB |
Output is correct |
43 |
Correct |
42 ms |
72824 KB |
Output is correct |
44 |
Correct |
39 ms |
72824 KB |
Output is correct |
45 |
Correct |
43 ms |
72952 KB |
Output is correct |
46 |
Correct |
39 ms |
72824 KB |
Output is correct |
47 |
Correct |
43 ms |
72832 KB |
Output is correct |
48 |
Correct |
39 ms |
72824 KB |
Output is correct |
49 |
Correct |
41 ms |
72824 KB |
Output is correct |
50 |
Correct |
46 ms |
72952 KB |
Output is correct |
51 |
Correct |
41 ms |
72824 KB |
Output is correct |
52 |
Correct |
39 ms |
72824 KB |
Output is correct |
53 |
Correct |
40 ms |
72824 KB |
Output is correct |
54 |
Correct |
48 ms |
72828 KB |
Output is correct |
55 |
Correct |
41 ms |
72824 KB |
Output is correct |
56 |
Correct |
41 ms |
72824 KB |
Output is correct |
57 |
Correct |
41 ms |
72824 KB |
Output is correct |
58 |
Correct |
39 ms |
72824 KB |
Output is correct |
59 |
Correct |
69 ms |
72832 KB |
Output is correct |
60 |
Correct |
42 ms |
72824 KB |
Output is correct |
61 |
Correct |
71 ms |
72884 KB |
Output is correct |
62 |
Correct |
42 ms |
72960 KB |
Output is correct |
63 |
Correct |
70 ms |
72920 KB |
Output is correct |
64 |
Correct |
41 ms |
72824 KB |
Output is correct |
65 |
Correct |
46 ms |
72824 KB |
Output is correct |
66 |
Correct |
45 ms |
72792 KB |
Output is correct |
67 |
Correct |
45 ms |
72824 KB |
Output is correct |
68 |
Correct |
43 ms |
72824 KB |
Output is correct |
69 |
Correct |
47 ms |
72956 KB |
Output is correct |
70 |
Correct |
46 ms |
72832 KB |
Output is correct |
71 |
Correct |
44 ms |
72824 KB |
Output is correct |
72 |
Correct |
45 ms |
72824 KB |
Output is correct |
73 |
Correct |
43 ms |
72824 KB |
Output is correct |
74 |
Correct |
45 ms |
72952 KB |
Output is correct |
75 |
Correct |
43 ms |
72824 KB |
Output is correct |
76 |
Correct |
53 ms |
72824 KB |
Output is correct |
77 |
Correct |
45 ms |
72824 KB |
Output is correct |
78 |
Correct |
48 ms |
72832 KB |
Output is correct |
79 |
Correct |
44 ms |
72832 KB |
Output is correct |
80 |
Correct |
55 ms |
72832 KB |
Output is correct |
81 |
Correct |
42 ms |
72824 KB |
Output is correct |
82 |
Correct |
48 ms |
72880 KB |
Output is correct |
83 |
Correct |
45 ms |
72828 KB |
Output is correct |
84 |
Correct |
47 ms |
72824 KB |
Output is correct |
85 |
Correct |
45 ms |
72824 KB |
Output is correct |
86 |
Correct |
50 ms |
72824 KB |
Output is correct |
87 |
Correct |
46 ms |
72824 KB |
Output is correct |
88 |
Correct |
51 ms |
72840 KB |
Output is correct |
89 |
Correct |
47 ms |
72824 KB |
Output is correct |
90 |
Correct |
43 ms |
72824 KB |
Output is correct |
91 |
Correct |
53 ms |
72824 KB |
Output is correct |
92 |
Correct |
54 ms |
72960 KB |
Output is correct |
93 |
Correct |
45 ms |
72824 KB |
Output is correct |