Submission #552784

#TimeUsernameProblemLanguageResultExecution timeMemory
552784toastifishiCollecting Stamps 3 (JOI20_ho_t3)C++14
100 / 100
147 ms132076 KiB
#include <bits/stdc++.h> #define x first #define y second using namespace std; using ll = long long; int n, L; const int MAXN = 205; ll dp[MAXN][MAXN][2][MAXN]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> n >> L; vector <ll> x(n + 2), t(n + 2); for(int i = 1; i <= n; i++) cin >> x[i]; for(int i = 1; i <= n; i++) cin >> t[i]; x[n + 1] = L; for(int i = 0; i <= n + 1; i++) { for(int j = 0; j <= n + 1; j++) { for(int k = 0; k < 2; k++) { for(int m = 0; m <= n; m++) dp[i][j][k][m] = 1e18; } } } dp[0][n + 1][0][0] = dp[0][n + 1][1][0] = 0; for(int i = 0; i < n; i++) { for(int j = n + 1; j >= i + 2; j--) { for(int m = 0; m <= n; m++) { ll T; T = min(dp[i][j][0][m] + x[i + 1] - x[i], dp[i][j][1][m] + x[i + 1] + L - x[j]); dp[i + 1][j][0][m + (T <= t[i + 1])] = min(dp[i + 1][j][0][m + (T <= t[i + 1])], T); T = min(dp[i][j][0][m] + x[i] + L - x[j - 1], dp[i][j][1][m] + x[j] - x[j - 1]); dp[i][j - 1][1][m + (T <= t[j - 1])] = min(dp[i][j - 1][1][m + (T <= t[j - 1])], T); } } } ll ans = 0; for(int i = 0; i <= n + 1; i++) { for(int j = 0; j <= n + 1; j++) { for(int k = 0; k < 2; k++) { for(int m = 0; m <= n; m++) { if(dp[i][j][k][m] != 1e18) ans = max(ans, (ll)m); } } } } cout << ans << "\n"; 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...