Submission #830530

# Submission time Handle Problem Language Result Execution time Memory
830530 2023-08-19T07:46:04 Z RaresFelix Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
82 ms 127412 KB
#include <bits/stdc++.h>

using namespace std;
const int MN = 201;
const int INF = 1e9 + 1;
using ll = long long;
int n, l, P[MN], T[MN];
ll DP[MN][MN][MN][2];
int dist(int p1, int p2) {
    return min(abs(p2 - p1), l - abs(p2 - p1));
}
int main() {
    cin >> n >> l;
    for(int i = 1; i <= n; ++i) 
        cin >> P[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 w = 0; w < 2; ++w) {
                    DP[i][j][k][w] = INF;
                }
            }
        }
    }
    DP[0][0][0][0] = 0;
    int re = 0;
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= n; ++j) {
            for(int k = 0; k <= n; ++k) {
                for(int w = 0; w < 2; ++w) {
                    if(DP[i][j][k][w] < INF) {
                        re = max(re, k);
                        if(i + j == n) continue; /// am vizitat tot
                        int poz = w ? P[j] : P[n - i + 1];
                        ///dreapta
                        int d = dist(poz, P[j + 1]), win = (T[j + 1] >= (d + DP[i][j][k][w]));
                        DP[i][j + 1][k + win][1] = min(DP[i][j + 1][k + win][1], d + DP[i][j][k][w]);

                        ///stanga
                        d = dist(poz, P[n - i]);
                        win = T[n - i] >= (d + DP[i][j][k][w]);
                        DP[i + 1][j][k + win][0] = min(DP[i + 1][j][k + win][0], d + DP[i][j][k][w]);
                    }
                }
            }
        }
    }

    cout << re << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 568 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 692 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 568 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 692 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 1 ms 948 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 852 KB Output is correct
25 Correct 1 ms 948 KB Output is correct
26 Correct 1 ms 980 KB Output is correct
27 Correct 0 ms 468 KB Output is correct
28 Correct 1 ms 564 KB Output is correct
29 Correct 1 ms 1080 KB Output is correct
30 Correct 1 ms 1108 KB Output is correct
31 Correct 1 ms 980 KB Output is correct
32 Correct 1 ms 852 KB Output is correct
33 Correct 1 ms 1108 KB Output is correct
34 Correct 1 ms 1108 KB Output is correct
35 Correct 1 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 568 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 692 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 60 ms 102804 KB Output is correct
19 Correct 41 ms 62444 KB Output is correct
20 Correct 19 ms 33312 KB Output is correct
21 Correct 34 ms 58928 KB Output is correct
22 Correct 46 ms 76372 KB Output is correct
23 Correct 17 ms 28396 KB Output is correct
24 Correct 12 ms 22168 KB Output is correct
25 Correct 16 ms 27708 KB Output is correct
26 Correct 4 ms 10580 KB Output is correct
27 Correct 17 ms 28996 KB Output is correct
28 Correct 11 ms 20684 KB Output is correct
29 Correct 16 ms 29600 KB Output is correct
30 Correct 12 ms 23284 KB Output is correct
31 Correct 15 ms 27684 KB Output is correct
32 Correct 8 ms 14548 KB Output is correct
33 Correct 17 ms 27888 KB Output is correct
34 Correct 4 ms 9940 KB Output is correct
35 Correct 14 ms 27172 KB Output is correct
36 Correct 6 ms 12884 KB Output is correct
37 Correct 15 ms 28980 KB Output is correct
38 Correct 8 ms 15828 KB Output is correct
39 Correct 16 ms 30208 KB Output is correct
40 Correct 9 ms 17724 KB Output is correct
41 Correct 79 ms 126780 KB Output is correct
42 Correct 41 ms 85476 KB Output is correct
43 Correct 79 ms 126692 KB Output is correct
44 Correct 41 ms 84468 KB Output is correct
45 Correct 82 ms 126956 KB Output is correct
46 Correct 41 ms 85516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 568 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 692 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 1 ms 948 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 852 KB Output is correct
25 Correct 1 ms 948 KB Output is correct
26 Correct 1 ms 980 KB Output is correct
27 Correct 0 ms 468 KB Output is correct
28 Correct 1 ms 564 KB Output is correct
29 Correct 1 ms 1080 KB Output is correct
30 Correct 1 ms 1108 KB Output is correct
31 Correct 1 ms 980 KB Output is correct
32 Correct 1 ms 852 KB Output is correct
33 Correct 1 ms 1108 KB Output is correct
34 Correct 1 ms 1108 KB Output is correct
35 Correct 1 ms 1108 KB Output is correct
36 Correct 60 ms 102804 KB Output is correct
37 Correct 41 ms 62444 KB Output is correct
38 Correct 19 ms 33312 KB Output is correct
39 Correct 34 ms 58928 KB Output is correct
40 Correct 46 ms 76372 KB Output is correct
41 Correct 17 ms 28396 KB Output is correct
42 Correct 12 ms 22168 KB Output is correct
43 Correct 16 ms 27708 KB Output is correct
44 Correct 4 ms 10580 KB Output is correct
45 Correct 17 ms 28996 KB Output is correct
46 Correct 11 ms 20684 KB Output is correct
47 Correct 16 ms 29600 KB Output is correct
48 Correct 12 ms 23284 KB Output is correct
49 Correct 15 ms 27684 KB Output is correct
50 Correct 8 ms 14548 KB Output is correct
51 Correct 17 ms 27888 KB Output is correct
52 Correct 4 ms 9940 KB Output is correct
53 Correct 14 ms 27172 KB Output is correct
54 Correct 6 ms 12884 KB Output is correct
55 Correct 15 ms 28980 KB Output is correct
56 Correct 8 ms 15828 KB Output is correct
57 Correct 16 ms 30208 KB Output is correct
58 Correct 9 ms 17724 KB Output is correct
59 Correct 79 ms 126780 KB Output is correct
60 Correct 41 ms 85476 KB Output is correct
61 Correct 79 ms 126692 KB Output is correct
62 Correct 41 ms 84468 KB Output is correct
63 Correct 82 ms 126956 KB Output is correct
64 Correct 41 ms 85516 KB Output is correct
65 Correct 57 ms 114520 KB Output is correct
66 Correct 52 ms 105112 KB Output is correct
67 Correct 51 ms 100628 KB Output is correct
68 Correct 46 ms 92892 KB Output is correct
69 Correct 56 ms 113424 KB Output is correct
70 Correct 57 ms 108700 KB Output is correct
71 Correct 53 ms 109780 KB Output is correct
72 Correct 58 ms 111044 KB Output is correct
73 Correct 52 ms 102936 KB Output is correct
74 Correct 53 ms 96212 KB Output is correct
75 Correct 50 ms 106312 KB Output is correct
76 Correct 75 ms 122052 KB Output is correct
77 Correct 58 ms 121860 KB Output is correct
78 Correct 58 ms 94016 KB Output is correct
79 Correct 49 ms 97228 KB Output is correct
80 Correct 74 ms 119480 KB Output is correct
81 Correct 49 ms 98428 KB Output is correct
82 Correct 59 ms 104060 KB Output is correct
83 Correct 62 ms 126764 KB Output is correct
84 Correct 60 ms 108608 KB Output is correct
85 Correct 67 ms 118228 KB Output is correct
86 Correct 72 ms 115824 KB Output is correct
87 Correct 52 ms 106340 KB Output is correct
88 Correct 68 ms 127296 KB Output is correct
89 Correct 63 ms 127360 KB Output is correct
90 Correct 50 ms 107428 KB Output is correct
91 Correct 68 ms 127412 KB Output is correct
92 Correct 64 ms 127376 KB Output is correct
93 Correct 59 ms 125648 KB Output is correct