Submission #922839

#TimeUsernameProblemLanguageResultExecution timeMemory
922839dimashhhCollecting Stamps 3 (JOI20_ho_t3)C++17
15 / 100
1 ms1628 KiB
#include <bits/stdc++.h> using namespace std; const int N = 212, MOD = 1e9 + 7; typedef long long ll; #define int ll int n,L,t[N],x[N]; pair<int,ll> dp[N][N][2]; void test() { 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 = 0;j <= n;j++){ for(int k =0 ;k < 2;k++){ dp[i][j][k] = {-1e9,-1e18}; } } } dp[0][0][0] = dp[0][0][1] = {0,0}; x[n + 1] = L; for(int i =0;i <=n;i++) { for(int j = 0;j <= n;j++){ if(i + j >= n) break; { dp[i + 1][j][0] = max(dp[i + 1][j][0], make_pair( dp[i][j][0].first + (-dp[i][j][0].second + x[i + 1] - x[i] <= t[i + 1]), dp[i][j][0].second - x[i + 1] + x[i])); dp[i + 1][j][0] = max(dp[i + 1][j][0], make_pair( dp[i][j][1].first + (-dp[i][j][1].second + L - x[n - j + 1] + x[i + 1] <= t[i + 1]), dp[i][j][1].second - (L - x[n - j + 1] + x[i + 1]))); dp[i + 1][j][1] = max(dp[i + 1][j][1], make_pair(dp[i + 1][j][0].first, dp[i + 1][j][0].second - (x[i + 1] + L - x[n - j + 1]))); } { dp[i][j + 1][1] = max({dp[i][j + 1][1], make_pair( dp[i][j][1].first + (-dp[i][j][1].second + x[n - j + 1] - x[n - j] <= t[n - j]), (dp[i][j][1].second - (x[n - j + 1] - x[n - j])))}); dp[i][j + 1][1] = max({dp[i][j + 1][1], make_pair( dp[i][j][0].first + (-dp[i][j][0].second + x[i] + L - x[n - j] <= t[n - j]), dp[i][j][0].second - (x[i] + L - x[n - j]))}); dp[i][j + 1][0] = max(dp[i][j + 1][0], make_pair(dp[i][j + 1][1].first, dp[i][j + 1][1].second - (x[i] + L - x[n - j ]))); } } } int res = 0; for(int i = 0;i <= n;i++){ for(int j = 0;j <= n;j++){ res = max({res,dp[i][j][0].first,dp[i][j][1].first}); } } cout << res << '\n'; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0); int T = 1; // cin >> T; while (T--) test(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...