Submission #364263

#TimeUsernameProblemLanguageResultExecution timeMemory
364263Lam_lai_cuoc_doiCollecting Stamps 3 (JOI20_ho_t3)C++17
100 / 100
151 ms135424 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; const bool typetest = 0; const int N = 2e2 + 5; const ll Inf = 1e17; int n; ll x[N], y[N], t[N]; ll dp[N][N][N][2], l; int ans(0); void Read() { cin >> n >> l; t[0] = -1; for (int i = 1; i <= n; ++i) { cin >> x[i]; y[i] = l - x[i]; } for (int i = 1; i <= n; ++i) cin >> t[i]; } int pos(int v) { v += n + 1; if (v >= n + 1) v -= n + 1; if (v >= n + 1) v -= n + 1; return v; } template <class T> inline void Min(T &x, T y) { if (x > y) x = y; } void Solve() { fill_n(&dp[0][0][0][0], N * N * N * 2, Inf); dp[0][0][0][0] = dp[0][0][0][1] = 0; for (int i = 0; i <= n; ++i) for (int j = 0; j <= n; ++j) for (int h = 0; h <= i; ++h) { if (dp[j][pos(j + i)][h][0] != Inf) { ans = max(ans, h); ll v = dp[j][pos(j + i)][h][0] + y[pos(j - 1)] - y[j]; Min(dp[pos(j - 1)][pos(j + i)][h + (v <= t[pos(j - 1)])][0], v); v = dp[j][pos(j + i)][h][0] + y[j] + x[pos(j + i + 1)]; Min(dp[j][pos(j + i + 1)][h + (v <= t[pos(j + i + 1)])][1], v); } if (dp[j][(j + i) % (n + 1)][h][1] != Inf) { ans = max(ans, h); ll v = dp[j][pos(j + i)][h][1] + x[pos(j + i + 1)] - x[pos(j + i)]; Min(dp[j][pos(j + i + 1)][h + (v <= t[pos(j + i + 1)])][1], v); v = dp[j][pos(j + i)][h][1] + x[pos(j + i)] + y[pos(j - 1)]; Min(dp[pos(j - 1)][pos(j + i)][h + (v <= t[pos(j - 1)])][0], v); } } cout << ans; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t(1); if (typetest) cin >> t; for (int _ = 1; _ <= t; ++_) { Read(); Solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...