Submission #227134

#TimeUsernameProblemLanguageResultExecution timeMemory
227134maruiiCollecting Stamps 3 (JOI20_ho_t3)C++14
100 / 100
74 ms66040 KiB
#include <bits/stdc++.h> using namespace std; int N, L, X[205], T[205], D[205][205][205][2], ans; int main() { ios_base::sync_with_stdio(0), cin.tie(0); 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 = 0; i <= N; ++i) for (int j = 1; j <= N + 1; ++j) for (int k = 0; k <= N; ++k) D[i][j][k][0] = D[i][j][k][1] = 1e9; X[N + 1] = L; D[0][N + 1][0][0] = D[0][N + 1][0][1] = 0; for (int i = 0; i <= N; ++i) { for (int j = N + 1; j > i; --j) { for (int k = 0; k <= N; ++k) { if (D[i][j][k][0] != 1e9 || D[i][j][k][1] != 1e9) ans = max(ans, k); if (D[i][j][k][0] + X[i + 1] - X[i] <= T[i + 1]) D[i + 1][j][k + 1][0] = min(D[i + 1][j][k + 1][0], D[i][j][k][0] + X[i + 1] - X[i]); else D[i + 1][j][k][0] = min(D[i + 1][j][k][0], D[i][j][k][0] + X[i + 1] - X[i]); if (D[i][j][k][0] + X[i] + L - X[j - 1] <= T[j - 1]) D[i][j - 1][k + 1][1] = min(D[i][j - 1][k + 1][1], D[i][j][k][0] + X[i] + L - X[j - 1]); else D[i][j - 1][k][1] = min(D[i][j - 1][k][1], D[i][j][k][0] + X[i] + L - X[j - 1]); if (D[i][j][k][1] + X[j] - X[j - 1] <= T[j - 1]) D[i][j - 1][k + 1][1] = min(D[i][j - 1][k + 1][1], D[i][j][k][1] + X[j] - X[j - 1]); else D[i][j - 1][k][1] = min(D[i][j - 1][k][1], D[i][j][k][1] + X[j] - X[j - 1]); if (D[i][j][k][1] + L - X[j] + X[i + 1] <= T[i + 1]) D[i + 1][j][k + 1][0] = min(D[i + 1][j][k + 1][0], D[i][j][k][1] + L - X[j] + X[i + 1]); else D[i + 1][j][k][0] = min(D[i + 1][j][k][0], D[i][j][k][1] + L - X[j] + X[i + 1]); } } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...