Submission #313375

#TimeUsernameProblemLanguageResultExecution timeMemory
313375sofapudenCollecting Stamps 3 (JOI20_ho_t3)C++14
0 / 100
73 ms133240 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 204; ll n,l, X[maxn], T[maxn], dp[maxn][maxn][2][maxn]; int main(){ ios::sync_with_stdio(0), cin.tie(0); memset(dp, 0x3f, sizeof dp); cin >> n >> l; for(int i = 1; i <= n; ++i)cin >> X[i]; X[n+1] = l; for(int i = 1; i <= n; ++i)cin >> T[i]; ++n; T[0] = -1; T[n] = -1; dp[0][n][0][0] = 0; dp[0][n][1][0] = 0; int ans = 0; for(int i = 0; i <= n; ++i){ for(int j = n; j >= i; --j){ for(int k = 0; k <= n; ++k){ if(i){ dp[i][j][0][k] = min(dp[i][j][0][k], dp[i-1][j][0][k] + X[i] - X[i-1]); } if(j != n){ dp[i][j][1][k] = min(dp[i][j][1][k], dp[i][j+1][1][k] + X[j+1] - X[j]); } if(k){ if(i && dp[i-1][j][0][k-1] + X[i] - X[i-1] <= T[i]){ dp[i][j][0][k] = min(dp[i][j][0][k], dp[i-1][j][0][k-1] + X[i] - X[i-1]); } if(j != n && dp[i][j+1][k-1][1] + X[j+1] - X[j] <= T[j]){ dp[i][j][1][k] = min(dp[i][j][1][k], dp[i][j+1][1][k-1] + X[j+1] - X[j]); } } dp[i][j][0][k] = min(dp[i][j][0][k], dp[i][j][1][k] + l - X[j] + X[i]); dp[i][j][1][k] = min(dp[i][j][1][k], dp[i][j][0][k] + l - X[j] + X[i]); if(min(dp[i][j][0][k],dp[i][j][1][k]) < 1000000000ll)ans = max(ans,k); } } } cout << ans << "\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...