This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// GPT TESTING
#include <bits/stdc++.h>
using namespace std;
const int N = 205;
int n, l, ans, x[N], t[N];
bool f[N][N * 2];
int main() {
cin >> n >> l;
for (int i = 1; i <= n; i++) {
cin >> x[i];
}
for (int i = 1; i <= n; i++) {
cin >> t[i];
}
for (int i = 1; i <= n; i++) {
memset(f, 0, sizeof f);
f[i][0] = true;
for (int j = i + 1; j <= n; j++) {
for (int k = 0; k < 2 * n; k++) {
if (!f[j - 1][k]) {
continue;
}
int d = abs(x[j] - x[j - 1]);
if (k + d <= t[j]) {
f[j][k + d] = true;
}
d = l - abs(x[j] - x[j - 1]);
if (k + d <= t[j]) {
f[j][k + d] = true;
}
}
}
for (int j = i - 1; j >= 1; j--) {
for (int k = 0; k < 2 * n; k++) {
if (!f[j + 1][k]) {
continue;
}
int d = abs(x[j + 1] - x[j]);
if (k + d <= t[j]) {
f[j][k + d] = true;
}
d = l - abs(x[j + 1] - x[j]);
if (k + d <= t[j]) {
f[j][k + d] = true;
}
}
}
int res = 0;
for (int j = 0; j < 2 * n; j++) {
if (f[1][j]) {
res = max(res, j / 2 + (j % 2 != 0));
}
}
for (int j = n; j >= 1; j--) {
for (int k = 0; k < 2 * n; k++) {
if (!f[j][k]) {
continue;
}
int d = abs(x[j] - x[n]);
if (k + d <= t[n]) {
res = max(res, (k + d) / 2 + ((k + d) % 2 != 0));
}
d = l - abs(x[j] - x[n]);
if (k + d <= t[n]) {
res = max(res, (k + d) / 2 + ((k + d) % 2 != 0));
}
}
}
ans = max(ans, res);
}
cout << ans << endl;
return 0;
}
# | 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... |