Submission #201361

# Submission time Handle Problem Language Result Execution time Memory
201361 2020-02-10T10:20:04 Z parsa_mobed Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
5 ms 1020 KB
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int N = 210, inf = 1e9 + 1;
int dp[N][N][N][2], X[N], T[N];

int32_t main()
{
    int n, L; 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 + 1; i++) for (int j = 0; j <= n + 1; j++) for (int c = 0; c <= n; c++) dp[i][j][c][0] = dp[i][j][c][1] = inf;
    T[0] = T[n+1] = -1;
    X[n+1] = L;
    dp[0][n+1][0][0] = dp[0][n+1][0][1] = 0;
    int ans = 0;
    for (int c = 0; c <= n; c++) {
        for (int i = 0; i <= n; i++) {
            for (int j = n + 1; j >= 1; j--) {
                if (i > 0) {
                    dp[i][j][c][0] = min(dp[i][j][c][0], min(dp[i - 1][j][c][0] + X[i] - X[i - 1], dp[i - 1][j][c][1] + X[i] + L - X[j]));
                    if (c > 0 && dp[i - 1][j][c - 1][0] + X[i] - X[i - 1] <= T[i])
                        dp[i][j][c][0] = min(dp[i][j][c][0], dp[i - 1][j][c - 1][0] + X[i] - X[i - 1]);
                    if (c > 0 && dp[i - 1][j][c - 1][1] + X[i] + L - X[j] <= T[i])
                        dp[i][j][c][0] = min(dp[i][j][c][0], dp[i - 1][j][c - 1][1] + X[i] + L - X[j]);
                }
                if (j < n + 1) {
                    dp[i][j][c][1] = min(dp[i][j][c][1], min(dp[i][j + 1][c][1] + X[j + 1] - X[j], dp[i][j + 1][c][0] + X[i] + L - X[j]));
                    if (c > 0 && dp[i][j + 1][c - 1][1] + X[j + 1] - X[j] <= T[j])
                        dp[i][j][c][1] = min(dp[i][j][c][1], dp[i][j + 1][c - 1][1] + X[j + 1] - X[j]);
                    if (c > 0 && dp[i][j + 1][c - 1][0] + X[i] + L - X[j] <= T[j])
                        dp[i][j][c][1] = min(dp[i][j][c][1], dp[i][j + 1][c - 1][0] + X[i] + L - X[j]);
                }
                if (dp[i][j][c][0] < inf || dp[i][j][c][1] < inf) ans = c;
            }
        }
    }
    cout << ans << "\n";


    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 508 KB Output is correct
3 Correct 5 ms 764 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 1016 KB Output is correct
13 Correct 5 ms 1016 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 636 KB Output is correct
16 Incorrect 5 ms 1020 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 508 KB Output is correct
3 Correct 5 ms 764 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 1016 KB Output is correct
13 Correct 5 ms 1016 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 636 KB Output is correct
16 Incorrect 5 ms 1020 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 508 KB Output is correct
3 Correct 5 ms 764 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 1016 KB Output is correct
13 Correct 5 ms 1016 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 636 KB Output is correct
16 Incorrect 5 ms 1020 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 508 KB Output is correct
3 Correct 5 ms 764 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 1016 KB Output is correct
13 Correct 5 ms 1016 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 636 KB Output is correct
16 Incorrect 5 ms 1020 KB Output isn't correct
17 Halted 0 ms 0 KB -