Submission #1239003

#TimeUsernameProblemLanguageResultExecution timeMemory
1239003trimkusCollecting Stamps 3 (JOI20_ho_t3)C++20
0 / 100
1 ms1092 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAXN = 205; ll dp[MAXN + 1][MAXN + 1][MAXN + 1][2]; void chmin(ll& x, ll y) { x = min(x, y); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; ll Lt; cin >> N >> Lt; vector<ll> x(N + 3); for (int i = 1; i <= N; ++i) { cin >> x[i]; } x[N + 1] = Lt; vector<ll> t(N + 3, -1); for (int i = 1; i <= N; ++i) { cin >> t[i]; } const ll INF = 1e18; for (int i = 0; i <= N + 2; ++i) { for (int j = 0; j <= N + 2; ++j) { for (int k = 0; k <= N + 2; ++k) { for (int l = 0; l < 2; ++l) { dp[i][j][k][l] = INF; } } } } dp[0][N + 1][0][0] = dp[0][N + 1][0][1] = 0; for (int l = 0; l < N; ++l) { for (int r = N + 1; r > l; --r) { for (int k = 0; k <= N; ++k) { ll tim = min(dp[l][r][k][0] + x[l + 1] - x[l], dp[l][r][k][1] + Lt + x[l + 1] - x[r]); if (tim <= t[l + 1]) { chmin(dp[l + 1][r][k + 1][0], tim); } else { chmin(dp[l + 1][r][k][0], tim); } tim = min(dp[l][r][k][0] + Lt + x[l] - x[r - 1], dp[l][r][k][1] + x[r] - x[r - 1]); if (tim <= t[r - 1]) { chmin(dp[l][r - 1][k + 1][1], tim); } else { chmin(dp[l][r - 1][k][1], tim); } } } } int res = 0; for (int i = 0; i <= N + 1; ++i) { for (int j = 0; j <= N + 1; ++j) { for (int k = 0; k <= N; ++k) { for (int z = 0; z < 2; ++z) { if (dp[i][j][k][z] >= INF) continue; res = max(res, k); } } } } cout << res << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...