Submission #492241

# Submission time Handle Problem Language Result Execution time Memory
492241 2021-12-06T05:46:37 Z SirCovidThe19th Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
185 ms 67808 KB
#include <bits/stdc++.h>
using namespace std; 

#define FOR(i, x, y) for (int i = x; i < y; i++)
#define MIN(a, b) a = min(a, b)

int n, L, ans, A[205], T[205]; int dp[205][205][205][2];

int main(){
    cin >> n >> L; n++;
	
    FOR(i, 1, n) cin >> A[i];
    FOR(i, 1, n) cin >> T[i];

    auto dst = [&](int a, int b){ return min(abs(a - b), L - abs(a - b)); };

    memset(dp, 0x3f, sizeof(dp)); dp[0][0][0][0] = dp[0][0][0][1] = 0;
    FOR(x, 0, n + 1) 
        FOR(sz, 1, n + 1) 
            for (int a = 0, b = sz - 1, flag = 1; a or flag; a = (a + 1) % n, b = (b + 1) % n, flag = 0)
                FOR(pos, 0, 2){
                    int &curT = dp[x][a][b][pos], curP = !pos ? a : b;
                    int nxA = (a - 1 + n) % n, nxB = (b + 1) % n;

                    if (curT <= 1e9) ans = x;
                    if (curT > 1e9 or sz == n) continue;
                    
                    int newT1 = curT + dst(A[curP], A[nxA]), use1 = x + (newT1 <= T[nxA]);
                    MIN(dp[use1][nxA][b][0], newT1);
        
                    int newT2 = curT + dst(A[curP], A[nxB]), use2 = x + (newT2 <= T[nxB]);
                    MIN(dp[use2][a][nxB][1], newT2);
                }
    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 24 ms 67660 KB Output is correct
2 Correct 24 ms 67712 KB Output is correct
3 Correct 25 ms 67680 KB Output is correct
4 Correct 25 ms 67708 KB Output is correct
5 Correct 26 ms 67612 KB Output is correct
6 Correct 26 ms 67592 KB Output is correct
7 Correct 27 ms 67720 KB Output is correct
8 Correct 26 ms 67704 KB Output is correct
9 Correct 24 ms 67660 KB Output is correct
10 Correct 25 ms 67632 KB Output is correct
11 Correct 24 ms 67644 KB Output is correct
12 Correct 26 ms 67652 KB Output is correct
13 Correct 27 ms 67728 KB Output is correct
14 Correct 24 ms 67644 KB Output is correct
15 Correct 25 ms 67652 KB Output is correct
16 Correct 25 ms 67660 KB Output is correct
17 Correct 24 ms 67604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 67660 KB Output is correct
2 Correct 24 ms 67712 KB Output is correct
3 Correct 25 ms 67680 KB Output is correct
4 Correct 25 ms 67708 KB Output is correct
5 Correct 26 ms 67612 KB Output is correct
6 Correct 26 ms 67592 KB Output is correct
7 Correct 27 ms 67720 KB Output is correct
8 Correct 26 ms 67704 KB Output is correct
9 Correct 24 ms 67660 KB Output is correct
10 Correct 25 ms 67632 KB Output is correct
11 Correct 24 ms 67644 KB Output is correct
12 Correct 26 ms 67652 KB Output is correct
13 Correct 27 ms 67728 KB Output is correct
14 Correct 24 ms 67644 KB Output is correct
15 Correct 25 ms 67652 KB Output is correct
16 Correct 25 ms 67660 KB Output is correct
17 Correct 24 ms 67604 KB Output is correct
18 Correct 25 ms 67648 KB Output is correct
19 Correct 25 ms 67600 KB Output is correct
20 Correct 24 ms 67684 KB Output is correct
21 Correct 25 ms 67612 KB Output is correct
22 Correct 26 ms 67660 KB Output is correct
23 Correct 25 ms 67732 KB Output is correct
24 Correct 25 ms 67732 KB Output is correct
25 Correct 26 ms 67660 KB Output is correct
26 Correct 26 ms 67616 KB Output is correct
27 Correct 24 ms 67660 KB Output is correct
28 Correct 24 ms 67692 KB Output is correct
29 Correct 25 ms 67660 KB Output is correct
30 Correct 28 ms 67624 KB Output is correct
31 Correct 25 ms 67624 KB Output is correct
32 Correct 25 ms 67608 KB Output is correct
33 Correct 25 ms 67612 KB Output is correct
34 Correct 25 ms 67736 KB Output is correct
35 Correct 25 ms 67660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 67660 KB Output is correct
2 Correct 24 ms 67712 KB Output is correct
3 Correct 25 ms 67680 KB Output is correct
4 Correct 25 ms 67708 KB Output is correct
5 Correct 26 ms 67612 KB Output is correct
6 Correct 26 ms 67592 KB Output is correct
7 Correct 27 ms 67720 KB Output is correct
8 Correct 26 ms 67704 KB Output is correct
9 Correct 24 ms 67660 KB Output is correct
10 Correct 25 ms 67632 KB Output is correct
11 Correct 24 ms 67644 KB Output is correct
12 Correct 26 ms 67652 KB Output is correct
13 Correct 27 ms 67728 KB Output is correct
14 Correct 24 ms 67644 KB Output is correct
15 Correct 25 ms 67652 KB Output is correct
16 Correct 25 ms 67660 KB Output is correct
17 Correct 24 ms 67604 KB Output is correct
18 Correct 134 ms 67664 KB Output is correct
19 Correct 91 ms 67728 KB Output is correct
20 Correct 45 ms 67708 KB Output is correct
21 Correct 73 ms 67704 KB Output is correct
22 Correct 103 ms 67712 KB Output is correct
23 Correct 43 ms 67600 KB Output is correct
24 Correct 36 ms 67612 KB Output is correct
25 Correct 42 ms 67660 KB Output is correct
26 Correct 29 ms 67696 KB Output is correct
27 Correct 46 ms 67616 KB Output is correct
28 Correct 35 ms 67644 KB Output is correct
29 Correct 42 ms 67660 KB Output is correct
30 Correct 35 ms 67660 KB Output is correct
31 Correct 41 ms 67692 KB Output is correct
32 Correct 33 ms 67660 KB Output is correct
33 Correct 41 ms 67660 KB Output is correct
34 Correct 29 ms 67692 KB Output is correct
35 Correct 37 ms 67660 KB Output is correct
36 Correct 28 ms 67628 KB Output is correct
37 Correct 40 ms 67764 KB Output is correct
38 Correct 32 ms 67704 KB Output is correct
39 Correct 42 ms 67660 KB Output is correct
40 Correct 34 ms 67656 KB Output is correct
41 Correct 179 ms 67708 KB Output is correct
42 Correct 91 ms 67660 KB Output is correct
43 Correct 181 ms 67660 KB Output is correct
44 Correct 94 ms 67708 KB Output is correct
45 Correct 185 ms 67708 KB Output is correct
46 Correct 90 ms 67708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 67660 KB Output is correct
2 Correct 24 ms 67712 KB Output is correct
3 Correct 25 ms 67680 KB Output is correct
4 Correct 25 ms 67708 KB Output is correct
5 Correct 26 ms 67612 KB Output is correct
6 Correct 26 ms 67592 KB Output is correct
7 Correct 27 ms 67720 KB Output is correct
8 Correct 26 ms 67704 KB Output is correct
9 Correct 24 ms 67660 KB Output is correct
10 Correct 25 ms 67632 KB Output is correct
11 Correct 24 ms 67644 KB Output is correct
12 Correct 26 ms 67652 KB Output is correct
13 Correct 27 ms 67728 KB Output is correct
14 Correct 24 ms 67644 KB Output is correct
15 Correct 25 ms 67652 KB Output is correct
16 Correct 25 ms 67660 KB Output is correct
17 Correct 24 ms 67604 KB Output is correct
18 Correct 25 ms 67648 KB Output is correct
19 Correct 25 ms 67600 KB Output is correct
20 Correct 24 ms 67684 KB Output is correct
21 Correct 25 ms 67612 KB Output is correct
22 Correct 26 ms 67660 KB Output is correct
23 Correct 25 ms 67732 KB Output is correct
24 Correct 25 ms 67732 KB Output is correct
25 Correct 26 ms 67660 KB Output is correct
26 Correct 26 ms 67616 KB Output is correct
27 Correct 24 ms 67660 KB Output is correct
28 Correct 24 ms 67692 KB Output is correct
29 Correct 25 ms 67660 KB Output is correct
30 Correct 28 ms 67624 KB Output is correct
31 Correct 25 ms 67624 KB Output is correct
32 Correct 25 ms 67608 KB Output is correct
33 Correct 25 ms 67612 KB Output is correct
34 Correct 25 ms 67736 KB Output is correct
35 Correct 25 ms 67660 KB Output is correct
36 Correct 134 ms 67664 KB Output is correct
37 Correct 91 ms 67728 KB Output is correct
38 Correct 45 ms 67708 KB Output is correct
39 Correct 73 ms 67704 KB Output is correct
40 Correct 103 ms 67712 KB Output is correct
41 Correct 43 ms 67600 KB Output is correct
42 Correct 36 ms 67612 KB Output is correct
43 Correct 42 ms 67660 KB Output is correct
44 Correct 29 ms 67696 KB Output is correct
45 Correct 46 ms 67616 KB Output is correct
46 Correct 35 ms 67644 KB Output is correct
47 Correct 42 ms 67660 KB Output is correct
48 Correct 35 ms 67660 KB Output is correct
49 Correct 41 ms 67692 KB Output is correct
50 Correct 33 ms 67660 KB Output is correct
51 Correct 41 ms 67660 KB Output is correct
52 Correct 29 ms 67692 KB Output is correct
53 Correct 37 ms 67660 KB Output is correct
54 Correct 28 ms 67628 KB Output is correct
55 Correct 40 ms 67764 KB Output is correct
56 Correct 32 ms 67704 KB Output is correct
57 Correct 42 ms 67660 KB Output is correct
58 Correct 34 ms 67656 KB Output is correct
59 Correct 179 ms 67708 KB Output is correct
60 Correct 91 ms 67660 KB Output is correct
61 Correct 181 ms 67660 KB Output is correct
62 Correct 94 ms 67708 KB Output is correct
63 Correct 185 ms 67708 KB Output is correct
64 Correct 90 ms 67708 KB Output is correct
65 Correct 131 ms 67780 KB Output is correct
66 Correct 119 ms 67708 KB Output is correct
67 Correct 109 ms 67652 KB Output is correct
68 Correct 101 ms 67708 KB Output is correct
69 Correct 127 ms 67704 KB Output is correct
70 Correct 127 ms 67704 KB Output is correct
71 Correct 126 ms 67788 KB Output is correct
72 Correct 128 ms 67700 KB Output is correct
73 Correct 116 ms 67660 KB Output is correct
74 Correct 110 ms 67708 KB Output is correct
75 Correct 116 ms 67652 KB Output is correct
76 Correct 172 ms 67704 KB Output is correct
77 Correct 136 ms 67704 KB Output is correct
78 Correct 124 ms 67660 KB Output is correct
79 Correct 105 ms 67708 KB Output is correct
80 Correct 169 ms 67808 KB Output is correct
81 Correct 107 ms 67660 KB Output is correct
82 Correct 127 ms 67708 KB Output is correct
83 Correct 142 ms 67716 KB Output is correct
84 Correct 142 ms 67780 KB Output is correct
85 Correct 148 ms 67704 KB Output is correct
86 Correct 146 ms 67676 KB Output is correct
87 Correct 115 ms 67708 KB Output is correct
88 Correct 157 ms 67704 KB Output is correct
89 Correct 145 ms 67660 KB Output is correct
90 Correct 117 ms 67660 KB Output is correct
91 Correct 159 ms 67708 KB Output is correct
92 Correct 144 ms 67728 KB Output is correct
93 Correct 140 ms 67788 KB Output is correct