# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201231 | ainta | Collecting Stamps 3 (JOI20_ho_t3) | C++17 | 83 ms | 132344 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int n;
long long X[410], Left[410][410][410], Right[410][410][410], T[410], L;
int main() {
int i, j, k;
scanf("%d%lld", &n, &L);
for (i = n + 1; i <= n + n; i++) scanf("%lld", &X[i]);
for (i = n + 1; i <= n + n; i++) scanf("%lld", &T[i]);
for (i = 0; i < n; i++) {
X[i] = X[n + 1 + i] - L;
T[i] = T[n + 1 + i];
}
for (i = n; i >= 0; i--) {
for (j = n - i; j <= n; j++) {
int b = j, e = j + i;
for (k = 0; k <= n; k++)Left[b][e][k] = Right[b][e][k] = -1e18;
Left[b][e][0] = Right[b][e][0] = 1e18;
for (k = 1; k <= n - i; k++) {
long long t1 = max(min(Left[b - 1][e][k - 1], T[b - 1]), Left[b - 1][e][k]) - (X[b] - X[b - 1]);
long long t2 = max(min(Right[b][e + 1][k - 1], T[e + 1]), Right[b][e + 1][k]) - (X[e + 1] - X[b]);
if (max(t1, t2) >= 0)Left[b][e][k] = max(t1, t2);
t1 = max(min(Left[b - 1][e][k - 1], T[b - 1]), Left[b - 1][e][k]) - (X[e] - X[b - 1]);
t2 = max(min(Right[b][e + 1][k - 1], T[e + 1]), Right[b][e + 1][k]) - (X[e + 1] - X[e]);
if (max(t1, t2) >= 0)Right[b][e][k] = max(t1, t2);
}
}
}
int res = 0;
for (i = 1; i <= n; i++)if (Left[n][n][i] >= 0 || Right[n][n][i]>=0)res = i;
printf("%d\n", res);
}
Compilation message (stderr)
# | 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... |