Submission #922861

#TimeUsernameProblemLanguageResultExecution timeMemory
922861dimashhhCollecting Stamps 3 (JOI20_ho_t3)C++17
100 / 100
54 ms142212 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]; ll dp[N][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 <= n;k++){ for(int f = 0;f < 2;++f){ dp[i][j][k][f] = 1e18; } } } } x[n + 1] = L; 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++){ if(i + j >= n) break; for(int k = 0;k <= i + j;k++){ int t1,t2,t3,t4; t1 = min(dp[i][j][k][1] + x[i + 1] + L - x[n - j + 1], dp[i][j][k][0] + x[i + 1] - x[i]);//i + 1,j,0 t2 = t1 + x[i + 1] + L - x[n - j + 1];//i + 1,j,1 t3 = min(dp[i][j][k][0] + x[i] + L - x[n - j], dp[i][j][k][1] - x[n - j] + x[n - j + 1]);//i,j + 1,1 t4 = t3 + x[i] + L - x[n - j];//i,j + 1,0 { dp[i + 1][j][k][0] = min(dp[i + 1][j][k][0],t1); if(t[i + 1] >= t1){ dp[i + 1][j][k + 1][0] = min(dp[i + 1][j][k + 1][0],t1); } } { dp[i + 1][j][k][1] = min(dp[i + 1][j][k][1],t2); } { dp[i][j + 1][k][1] = min(dp[i][j + 1][k][1],t3); if(t[n - j] >= t3){ dp[i][j + 1][k + 1][1] = min(dp[i][j + 1][k + 1][1],t3); } } { dp[i][j + 1][k][0] = min(dp[i][j + 1][k][0],t4); } } } } int res = 0; for(int i = 0;i <= n;i++){ for(int j = 0;j <= n;++j){ if(i + j > n) break; for(int k = 0;k <= i + j;k++){ if(min(dp[i][j][k][0],dp[i][j][k][1]) != 1e18){ res = max(res,k); } } } } 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...