//君の手を握ってしまったら
//孤独を知らないこの街には
//もう二度と帰ってくることはできないのでしょう
//君が手を差し伸べた 光で影が生まれる
//歌って聞かせて この話の続き
//連れて行って見たことない星まで
//さユリ - 花の塔
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
template<typename T> void chmin(T &a, T b){if(a > b) a = b;}
template<typename T> void chmax(T &a, T b){if(a < b) a = b;}
int dp[205][205][205][2];
void solve(){
int N, L, ans = 0; cin >> N >> L;
vector<int> X(N + 2, 0), T(N + 2, 0);
for(int i = 1; i <= N; ++i) cin >> X[i];
for(int i = 1; i <= N; ++i) cin >> T[i];
X[N + 1] = L;
for(int i = 0; i <= N; ++i){
for(int j = 0; i + j <= N; ++j){
for(int k = 0; k <= N; ++k){
dp[i][j][k][0] = dp[i][j][k][1] = (1ll<<60);
}
}
}
dp[0][0][0][0] = dp[0][0][0][1] = 0;
for(int i = 0; i <= N; ++i){
for(int j = 0; i + j <= N; ++j){
for(int k = 0; k <= i + j; ++k){
int t1 = X[N - j + 1] - X[N - j], t2 = X[i] + L - X[N - j];
chmin(dp[i][j + 1][k + (dp[i][j][k][1] + t1 <= T[N - j])][1], dp[i][j][k][1] + t1);
chmin(dp[i][j + 1][k + (dp[i][j][k][0] + t2 <= T[N - j])][1], dp[i][j][k][0] + t2);
t1 = X[i + 1] - X[i], t2 = L - X[N - j] + X[i + 1];
chmin(dp[i + 1][j][k + (dp[i][j][k][0] + t1 <= T[i + 1])][0], dp[i][j][k][0] + t1);
chmin(dp[i + 1][j][k + (dp[i][j][k][1] + t2 <= T[i + 1])][0], dp[i][j][k][1] + t2);
}
}
}
for(int i = 0; i <= N; ++i){
for(int j = 0; i + j <= N; ++j){
for(int k = 0; k <= i + j; ++k){
if(dp[i][j][k][0] < (1ll<<60)) chmax(ans, k);
if(dp[i][j][k][1] < (1ll<<60)) chmax(ans, k);
}
}
}
cout << ans << '\n';
}
signed main(){
starburst
int t = 1; //cin >> t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |