#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("WINTER.inp");
ofstream fout("WINTER.out");
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
const ll mod = 1e9 + 7;
const int mxn = 2e5 + 5, mxm = 1e5;
ll dp[2][205][205][205],n , l, x[205], t[205];
void ckmin(ll &a, ll b){
if(a > b)a = b;
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> l;
forr(i, 1, n + 1)cin >> x[i];
forr(i, 1, n + 1)cin >> t[i];
x[n + 1] = l;
forr(i, 0, n + 2){
forr(j, 0, n + 2){
forr(k, 0, n + 2){
dp[0][i][j][k] = dp[1][i][j][k] = 1e16;
}
}
}
dp[0][0][n + 1][0] = dp[1][0][n + 1][0] = 0;
for(int l = 0; l < n; l++){
for(int r = n + 1; r >= l + 2; r--){
for(int take = 0; take <= n; take++){
ll tt = min(dp[0][l][r][take] + abs(x[l + 1] - x[l]), dp[1][l][r][take] + abs(x[r] - x[l + 1]));
ckmin(dp[0][l + 1][r][take + (tt <= t[l + 1])], tt);
tt = min(dp[0][l][r][take] + abs(x[l] - x[r - 1]), dp[1][l][r][take] + abs(x[r] - x[r - 1]));
ckmin(dp[0][l][r - 1][take + (tt <= t[r - 1])], tt);
}
}
}
int ans = 0;
for(int i = 0; i <= n + 1; i++){
for(int j = 0; j <= n + 1; j++){
for(int k = 0; k <= n; k++){
if(dp[0][i][j][k] < 1e15 || dp[1][i][j][k] < 1e15){
ans = max(ans, k);
}
}
}
}
cout << ans;
return(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |