이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 2e2 + 5;
int ans = 0, L, mx=0;
bool mark[maxn][maxn][maxn][2];
int T[maxn], X[maxn];
void solve(int l, int r, int s, int d, int t){
if(mark[l][r][s][d]) return;
mark[l][r][s][d] = true;
ans = max(ans, s);
if(l==r-1 || t>mx) return;
if(d==0){
int t1 = X[l+1]-X[l];
int add1 = (t1+t <= T[l+1]);
int t2 = X[l]+(L-X[r-1]);
int add2 = (t2+t <= T[r-1]);
solve(l+1, r, s+add1, d, t+t1);
solve(l, r-1, s+add2, 1-d, t+t2);
}
else{
int t1 = X[r]-X[r-1];
int add1 = (t1+t <= T[r-1]);
int t2 = X[l+1]+(L-X[r]);
int add2 = (t2+t <= T[l+1]);
solve(l, r-1, s+add1, d, t+t1);
solve(l+1, r, s+add2, 1-d, t+t2);
}
}
int32_t main(){
int n; cin >> n >> L;
for(int i = 1; i <= n; i++) cin >> X[i];
for(int i = 1; i <= n; i++) cin >> T[i], mx = max(mx, T[i]);
solve(0, n+1, 0, 0, 0);
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... |