이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N = 201;
int t[N], x[N], ans;
int dp[N][N][N][2];
void update(int l,int r,int cnt,int j,int time)
{
int cur = l;
if(j) cur = r;
if(t[cur] >= time) cnt++;
int &curr = dp[l][r][cnt][j];
if(curr == -1 || curr > time) curr = time;
ans = max(ans, cnt);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, la, i, j, k;
cin>>n>>la;
for(i = 1; i <= n; i++)
cin>>x[i];
for(i = 1; i <= n; i++)
cin>>t[i];
memset(dp, -1, sizeof(dp));
x[0] = 0;
update(1, n, 0, 0, x[1]);
update(1, n, 0, 1, la - x[n]);
for(i = 1; i <= n; i++)
for(j = 1; j <= i; j++)
for(k = 0; k <= i; k++)
{
int l = j;
int r = n - i + j;
if(l >= r) continue;
if(dp[l][r][k][0] != -1)
{
int time = dp[l][r][k][0];
update(l+1, r, k, 0, time + x[l+1] - x[l]);
update(l+1, r, k, 1, time + x[l] + la - x[r]);
}
if(dp[l][r][k][1] != -1)
{
int time = dp[l][r][k][1];
update(l, r-1, k, 1, time + x[r] - x[r-1]);
update(l, r-1, k, 0, time + la - x[r] + x[l]);
}
}
cout<<ans<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |