Submission #556883

# Submission time Handle Problem Language Result Execution time Memory
556883 2022-05-04T09:31:19 Z alextodoran Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
77 ms 64512 KB
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 200;

const int INF = INT_MAX / 2;
const int LEFT = 0;
const int RIGHT = 1;

int N, L;
int X[N_MAX + 2];
int T[N_MAX + 2];

int minT[N_MAX + 2][N_MAX + 2][N_MAX + 2][2];
// minT[k][l][r][last] = Minimum time required to get k stamps,
// visiting the first l stands and the last r stands,
// the final position being at l or at r depending on last

void update (int &x, const int &y) {
    if (y < x) {
        x = y;
    }
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N >> L;
    for (int i = 1; i <= N; i++) {
        cin >> X[i];
    }
    for (int i = 1; i <= N; i++) {
        cin >> T[i];
    }
    X[0] = 0;
    X[N + 1] = L;

    for (int k = 0; k <= N; k++) {
        for (int l = 0; l <= N; l++) {
            for (int r = 0; r <= N; r++) {
                minT[k][l][r][LEFT] = INF;
                minT[k][l][r][RIGHT] = INF;
            }
        }
    }
    minT[0][0][0][LEFT] = 0;
    minT[0][0][0][RIGHT] = 0;
    for (int k = 0; k <= N; k++) {
        for (int l = 0; l <= N; l++) {
            for (int r = 0; l + r < N; r++) {
                int swpSide = X[l] + (L - X[(N + 1) - r]);
                update(minT[k][l][r][LEFT], minT[k][l][r][RIGHT] + swpSide);
                update(minT[k][l][r][RIGHT], minT[k][l][r][LEFT] + swpSide);
                int newTLeft = minT[k][l][r][LEFT] + (X[l + 1] - X[l]);
                int newTRight = minT[k][l][r][RIGHT] + (X[(N + 1) - r] - X[(N + 1) - (r + 1)]);
                update(minT[k + (newTLeft <= T[l + 1])][l + 1][r][LEFT], newTLeft);
                update(minT[k + (newTRight <= T[(N + 1) - (r + 1)])][l][r + 1][RIGHT], newTRight);
            }
        }
    }

    int answer = 0;
    for (int k = 0; k <= N; k++) {
        for (int l = 0; l <= N; l++) {
            for (int r = (l == 0); l + r <= N; r++) {
                if (minT[k][l][r][LEFT] != INF || minT[k][l][r][RIGHT] != INF) {
                    answer = k;
                }
            }
        }
    }
    cout << answer << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 580 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 580 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 580 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 584 KB Output is correct
21 Correct 1 ms 716 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 596 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 456 KB Output is correct
29 Correct 1 ms 724 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 1 ms 724 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 1 ms 724 KB Output is correct
35 Correct 1 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 580 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 580 KB Output is correct
18 Correct 49 ms 52132 KB Output is correct
19 Correct 28 ms 31828 KB Output is correct
20 Correct 14 ms 17108 KB Output is correct
21 Correct 26 ms 30036 KB Output is correct
22 Correct 38 ms 38868 KB Output is correct
23 Correct 12 ms 14548 KB Output is correct
24 Correct 10 ms 11476 KB Output is correct
25 Correct 12 ms 14292 KB Output is correct
26 Correct 5 ms 5588 KB Output is correct
27 Correct 11 ms 14804 KB Output is correct
28 Correct 7 ms 10720 KB Output is correct
29 Correct 12 ms 15232 KB Output is correct
30 Correct 9 ms 11988 KB Output is correct
31 Correct 12 ms 14292 KB Output is correct
32 Correct 6 ms 7624 KB Output is correct
33 Correct 13 ms 14280 KB Output is correct
34 Correct 4 ms 5204 KB Output is correct
35 Correct 14 ms 13908 KB Output is correct
36 Correct 5 ms 6740 KB Output is correct
37 Correct 14 ms 14804 KB Output is correct
38 Correct 6 ms 8268 KB Output is correct
39 Correct 13 ms 15444 KB Output is correct
40 Correct 6 ms 9172 KB Output is correct
41 Correct 77 ms 64128 KB Output is correct
42 Correct 34 ms 43476 KB Output is correct
43 Correct 66 ms 64092 KB Output is correct
44 Correct 35 ms 42828 KB Output is correct
45 Correct 65 ms 64212 KB Output is correct
46 Correct 46 ms 43452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 580 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 580 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 584 KB Output is correct
21 Correct 1 ms 716 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 596 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 456 KB Output is correct
29 Correct 1 ms 724 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 1 ms 724 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 1 ms 724 KB Output is correct
35 Correct 1 ms 724 KB Output is correct
36 Correct 49 ms 52132 KB Output is correct
37 Correct 28 ms 31828 KB Output is correct
38 Correct 14 ms 17108 KB Output is correct
39 Correct 26 ms 30036 KB Output is correct
40 Correct 38 ms 38868 KB Output is correct
41 Correct 12 ms 14548 KB Output is correct
42 Correct 10 ms 11476 KB Output is correct
43 Correct 12 ms 14292 KB Output is correct
44 Correct 5 ms 5588 KB Output is correct
45 Correct 11 ms 14804 KB Output is correct
46 Correct 7 ms 10720 KB Output is correct
47 Correct 12 ms 15232 KB Output is correct
48 Correct 9 ms 11988 KB Output is correct
49 Correct 12 ms 14292 KB Output is correct
50 Correct 6 ms 7624 KB Output is correct
51 Correct 13 ms 14280 KB Output is correct
52 Correct 4 ms 5204 KB Output is correct
53 Correct 14 ms 13908 KB Output is correct
54 Correct 5 ms 6740 KB Output is correct
55 Correct 14 ms 14804 KB Output is correct
56 Correct 6 ms 8268 KB Output is correct
57 Correct 13 ms 15444 KB Output is correct
58 Correct 6 ms 9172 KB Output is correct
59 Correct 77 ms 64128 KB Output is correct
60 Correct 34 ms 43476 KB Output is correct
61 Correct 66 ms 64092 KB Output is correct
62 Correct 35 ms 42828 KB Output is correct
63 Correct 65 ms 64212 KB Output is correct
64 Correct 46 ms 43452 KB Output is correct
65 Correct 60 ms 58044 KB Output is correct
66 Correct 47 ms 53284 KB Output is correct
67 Correct 46 ms 51028 KB Output is correct
68 Correct 42 ms 47196 KB Output is correct
69 Correct 51 ms 57492 KB Output is correct
70 Correct 53 ms 55176 KB Output is correct
71 Correct 48 ms 55636 KB Output is correct
72 Correct 59 ms 56324 KB Output is correct
73 Correct 43 ms 52180 KB Output is correct
74 Correct 43 ms 48852 KB Output is correct
75 Correct 43 ms 53972 KB Output is correct
76 Correct 58 ms 61852 KB Output is correct
77 Correct 62 ms 61772 KB Output is correct
78 Correct 46 ms 47748 KB Output is correct
79 Correct 42 ms 49352 KB Output is correct
80 Correct 58 ms 60596 KB Output is correct
81 Correct 42 ms 49980 KB Output is correct
82 Correct 50 ms 52832 KB Output is correct
83 Correct 53 ms 64164 KB Output is correct
84 Correct 50 ms 55112 KB Output is correct
85 Correct 57 ms 59996 KB Output is correct
86 Correct 64 ms 58748 KB Output is correct
87 Correct 46 ms 53856 KB Output is correct
88 Correct 60 ms 64468 KB Output is correct
89 Correct 57 ms 64512 KB Output is correct
90 Correct 45 ms 54540 KB Output is correct
91 Correct 57 ms 64512 KB Output is correct
92 Correct 56 ms 64468 KB Output is correct
93 Correct 56 ms 63656 KB Output is correct