//by szh
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
void MIN(int &a,int b) {
if (a==-1) a = b;
else a = min(a,b);
}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
const int maxn = 222;
int n,len;
int pos[maxn];
int dp[maxn][maxn][maxn][2];
int t[maxn];
int big;
int ans = 0;
int main() {
// freopen("input.txt","r",stdin);
std::ios::sync_with_stdio(false);cin.tie(0);
memset(dp,-1,sizeof(dp));
dp[0][0][0][0] = dp[0][0][0][1] = 0;
cin>>n>>len;
pos[0] = 0,pos[n+1] = len;
rep(i,1,n+1) cin>>pos[i];
rep(i,1,n+1) cin>>t[i];
rep(i,0,n+1)
rep(j,0,n-i+1)
rep(k,0,i+j+1) {
// cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k][0]<<" "<<dp[i][j][k][1]<<endl;
if (dp[i][j][k][0]!=-1) {
ans = max(ans,k);
int tn = dp[i][j][k][0] + pos[i+1]-pos[i];
// debug(tn);
MIN(dp[i+1][j][k+(tn<=t[i+1])][0],tn);
tn = dp[i][j][k][0] + pos[i] + len-pos[n-j];
// debug(tn);
MIN(dp[i][j+1][k+(tn<=t[n-j])][1],tn);
}
if (dp[i][j][k][1]!=-1) {
ans = max(ans,k);
int tn = dp[i][j][k][1] + pos[n-j+1] - pos[n-j];
// debug(tn);
MIN(dp[i][j+1][k+(tn<=t[n-j])][1],tn);
tn = dp[i][j][k][1] + len-pos[n-j+1] + pos[i+1];
// debug(tn);
MIN(dp[i+1][j][k+(tn<=t[i+1])][0],tn);
}
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
85840 KB |
Output is correct |
2 |
Correct |
31 ms |
85924 KB |
Output is correct |
3 |
Correct |
32 ms |
85964 KB |
Output is correct |
4 |
Correct |
32 ms |
85904 KB |
Output is correct |
5 |
Correct |
32 ms |
85836 KB |
Output is correct |
6 |
Correct |
35 ms |
85880 KB |
Output is correct |
7 |
Correct |
32 ms |
85880 KB |
Output is correct |
8 |
Correct |
31 ms |
85844 KB |
Output is correct |
9 |
Correct |
33 ms |
85948 KB |
Output is correct |
10 |
Correct |
37 ms |
85928 KB |
Output is correct |
11 |
Correct |
35 ms |
85852 KB |
Output is correct |
12 |
Correct |
34 ms |
85944 KB |
Output is correct |
13 |
Correct |
40 ms |
85840 KB |
Output is correct |
14 |
Correct |
38 ms |
85860 KB |
Output is correct |
15 |
Correct |
34 ms |
85960 KB |
Output is correct |
16 |
Correct |
33 ms |
85932 KB |
Output is correct |
17 |
Correct |
33 ms |
85948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
85840 KB |
Output is correct |
2 |
Correct |
31 ms |
85924 KB |
Output is correct |
3 |
Correct |
32 ms |
85964 KB |
Output is correct |
4 |
Correct |
32 ms |
85904 KB |
Output is correct |
5 |
Correct |
32 ms |
85836 KB |
Output is correct |
6 |
Correct |
35 ms |
85880 KB |
Output is correct |
7 |
Correct |
32 ms |
85880 KB |
Output is correct |
8 |
Correct |
31 ms |
85844 KB |
Output is correct |
9 |
Correct |
33 ms |
85948 KB |
Output is correct |
10 |
Correct |
37 ms |
85928 KB |
Output is correct |
11 |
Correct |
35 ms |
85852 KB |
Output is correct |
12 |
Correct |
34 ms |
85944 KB |
Output is correct |
13 |
Correct |
40 ms |
85840 KB |
Output is correct |
14 |
Correct |
38 ms |
85860 KB |
Output is correct |
15 |
Correct |
34 ms |
85960 KB |
Output is correct |
16 |
Correct |
33 ms |
85932 KB |
Output is correct |
17 |
Correct |
33 ms |
85948 KB |
Output is correct |
18 |
Incorrect |
32 ms |
85888 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
85840 KB |
Output is correct |
2 |
Correct |
31 ms |
85924 KB |
Output is correct |
3 |
Correct |
32 ms |
85964 KB |
Output is correct |
4 |
Correct |
32 ms |
85904 KB |
Output is correct |
5 |
Correct |
32 ms |
85836 KB |
Output is correct |
6 |
Correct |
35 ms |
85880 KB |
Output is correct |
7 |
Correct |
32 ms |
85880 KB |
Output is correct |
8 |
Correct |
31 ms |
85844 KB |
Output is correct |
9 |
Correct |
33 ms |
85948 KB |
Output is correct |
10 |
Correct |
37 ms |
85928 KB |
Output is correct |
11 |
Correct |
35 ms |
85852 KB |
Output is correct |
12 |
Correct |
34 ms |
85944 KB |
Output is correct |
13 |
Correct |
40 ms |
85840 KB |
Output is correct |
14 |
Correct |
38 ms |
85860 KB |
Output is correct |
15 |
Correct |
34 ms |
85960 KB |
Output is correct |
16 |
Correct |
33 ms |
85932 KB |
Output is correct |
17 |
Correct |
33 ms |
85948 KB |
Output is correct |
18 |
Correct |
53 ms |
85860 KB |
Output is correct |
19 |
Correct |
44 ms |
85868 KB |
Output is correct |
20 |
Correct |
37 ms |
85944 KB |
Output is correct |
21 |
Correct |
44 ms |
85948 KB |
Output is correct |
22 |
Correct |
51 ms |
85856 KB |
Output is correct |
23 |
Correct |
37 ms |
85836 KB |
Output is correct |
24 |
Correct |
36 ms |
85968 KB |
Output is correct |
25 |
Correct |
37 ms |
85848 KB |
Output is correct |
26 |
Correct |
35 ms |
85876 KB |
Output is correct |
27 |
Correct |
38 ms |
85844 KB |
Output is correct |
28 |
Correct |
34 ms |
85836 KB |
Output is correct |
29 |
Correct |
38 ms |
85940 KB |
Output is correct |
30 |
Correct |
34 ms |
85852 KB |
Output is correct |
31 |
Correct |
36 ms |
85844 KB |
Output is correct |
32 |
Correct |
35 ms |
85836 KB |
Output is correct |
33 |
Correct |
44 ms |
85844 KB |
Output is correct |
34 |
Correct |
35 ms |
85924 KB |
Output is correct |
35 |
Correct |
35 ms |
85836 KB |
Output is correct |
36 |
Correct |
36 ms |
85836 KB |
Output is correct |
37 |
Correct |
34 ms |
85964 KB |
Output is correct |
38 |
Correct |
41 ms |
85880 KB |
Output is correct |
39 |
Correct |
37 ms |
85852 KB |
Output is correct |
40 |
Correct |
34 ms |
85900 KB |
Output is correct |
41 |
Correct |
73 ms |
85916 KB |
Output is correct |
42 |
Correct |
35 ms |
85844 KB |
Output is correct |
43 |
Correct |
68 ms |
85956 KB |
Output is correct |
44 |
Correct |
35 ms |
85884 KB |
Output is correct |
45 |
Correct |
70 ms |
85840 KB |
Output is correct |
46 |
Correct |
36 ms |
85932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
85840 KB |
Output is correct |
2 |
Correct |
31 ms |
85924 KB |
Output is correct |
3 |
Correct |
32 ms |
85964 KB |
Output is correct |
4 |
Correct |
32 ms |
85904 KB |
Output is correct |
5 |
Correct |
32 ms |
85836 KB |
Output is correct |
6 |
Correct |
35 ms |
85880 KB |
Output is correct |
7 |
Correct |
32 ms |
85880 KB |
Output is correct |
8 |
Correct |
31 ms |
85844 KB |
Output is correct |
9 |
Correct |
33 ms |
85948 KB |
Output is correct |
10 |
Correct |
37 ms |
85928 KB |
Output is correct |
11 |
Correct |
35 ms |
85852 KB |
Output is correct |
12 |
Correct |
34 ms |
85944 KB |
Output is correct |
13 |
Correct |
40 ms |
85840 KB |
Output is correct |
14 |
Correct |
38 ms |
85860 KB |
Output is correct |
15 |
Correct |
34 ms |
85960 KB |
Output is correct |
16 |
Correct |
33 ms |
85932 KB |
Output is correct |
17 |
Correct |
33 ms |
85948 KB |
Output is correct |
18 |
Incorrect |
32 ms |
85888 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |