Submission #922858

# Submission time Handle Problem Language Result Execution time Memory
922858 2024-02-06T08:18:26 Z vjudge1 Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
65 ms 140892 KB
#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 time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 2 ms 8540 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 6648 KB Output is correct
6 Correct 1 ms 10588 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 10588 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 10764 KB Output is correct
13 Correct 2 ms 10588 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 1 ms 10588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 2 ms 8540 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 6648 KB Output is correct
6 Correct 1 ms 10588 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 10588 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 10764 KB Output is correct
13 Correct 2 ms 10588 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 1 ms 10588 KB Output is correct
18 Correct 2 ms 10588 KB Output is correct
19 Correct 1 ms 8540 KB Output is correct
20 Correct 1 ms 10588 KB Output is correct
21 Correct 2 ms 10584 KB Output is correct
22 Correct 1 ms 8540 KB Output is correct
23 Correct 2 ms 12636 KB Output is correct
24 Correct 2 ms 10584 KB Output is correct
25 Correct 2 ms 10588 KB Output is correct
26 Correct 2 ms 10588 KB Output is correct
27 Correct 1 ms 6488 KB Output is correct
28 Correct 1 ms 8536 KB Output is correct
29 Correct 2 ms 12812 KB Output is correct
30 Correct 2 ms 12636 KB Output is correct
31 Correct 2 ms 10588 KB Output is correct
32 Correct 2 ms 10588 KB Output is correct
33 Correct 2 ms 12636 KB Output is correct
34 Correct 2 ms 12636 KB Output is correct
35 Correct 2 ms 12636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 2 ms 8540 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 6648 KB Output is correct
6 Correct 1 ms 10588 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 10588 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 10764 KB Output is correct
13 Correct 2 ms 10588 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 1 ms 10588 KB Output is correct
18 Correct 60 ms 127840 KB Output is correct
19 Correct 28 ms 98908 KB Output is correct
20 Correct 17 ms 72280 KB Output is correct
21 Correct 26 ms 97088 KB Output is correct
22 Correct 34 ms 109144 KB Output is correct
23 Correct 13 ms 66276 KB Output is correct
24 Correct 11 ms 59996 KB Output is correct
25 Correct 12 ms 66236 KB Output is correct
26 Correct 7 ms 41644 KB Output is correct
27 Correct 13 ms 68188 KB Output is correct
28 Correct 10 ms 57948 KB Output is correct
29 Correct 14 ms 68348 KB Output is correct
30 Correct 11 ms 59992 KB Output is correct
31 Correct 13 ms 66140 KB Output is correct
32 Correct 8 ms 47808 KB Output is correct
33 Correct 14 ms 66140 KB Output is correct
34 Correct 6 ms 39632 KB Output is correct
35 Correct 12 ms 66136 KB Output is correct
36 Correct 7 ms 45660 KB Output is correct
37 Correct 14 ms 68368 KB Output is correct
38 Correct 8 ms 49888 KB Output is correct
39 Correct 15 ms 68292 KB Output is correct
40 Correct 9 ms 53852 KB Output is correct
41 Correct 65 ms 140484 KB Output is correct
42 Correct 38 ms 117356 KB Output is correct
43 Correct 63 ms 140380 KB Output is correct
44 Correct 35 ms 115536 KB Output is correct
45 Correct 63 ms 140584 KB Output is correct
46 Correct 36 ms 117584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 2 ms 8540 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 6648 KB Output is correct
6 Correct 1 ms 10588 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 10588 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 10764 KB Output is correct
13 Correct 2 ms 10588 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 1 ms 10588 KB Output is correct
18 Correct 2 ms 10588 KB Output is correct
19 Correct 1 ms 8540 KB Output is correct
20 Correct 1 ms 10588 KB Output is correct
21 Correct 2 ms 10584 KB Output is correct
22 Correct 1 ms 8540 KB Output is correct
23 Correct 2 ms 12636 KB Output is correct
24 Correct 2 ms 10584 KB Output is correct
25 Correct 2 ms 10588 KB Output is correct
26 Correct 2 ms 10588 KB Output is correct
27 Correct 1 ms 6488 KB Output is correct
28 Correct 1 ms 8536 KB Output is correct
29 Correct 2 ms 12812 KB Output is correct
30 Correct 2 ms 12636 KB Output is correct
31 Correct 2 ms 10588 KB Output is correct
32 Correct 2 ms 10588 KB Output is correct
33 Correct 2 ms 12636 KB Output is correct
34 Correct 2 ms 12636 KB Output is correct
35 Correct 2 ms 12636 KB Output is correct
36 Correct 60 ms 127840 KB Output is correct
37 Correct 28 ms 98908 KB Output is correct
38 Correct 17 ms 72280 KB Output is correct
39 Correct 26 ms 97088 KB Output is correct
40 Correct 34 ms 109144 KB Output is correct
41 Correct 13 ms 66276 KB Output is correct
42 Correct 11 ms 59996 KB Output is correct
43 Correct 12 ms 66236 KB Output is correct
44 Correct 7 ms 41644 KB Output is correct
45 Correct 13 ms 68188 KB Output is correct
46 Correct 10 ms 57948 KB Output is correct
47 Correct 14 ms 68348 KB Output is correct
48 Correct 11 ms 59992 KB Output is correct
49 Correct 13 ms 66140 KB Output is correct
50 Correct 8 ms 47808 KB Output is correct
51 Correct 14 ms 66140 KB Output is correct
52 Correct 6 ms 39632 KB Output is correct
53 Correct 12 ms 66136 KB Output is correct
54 Correct 7 ms 45660 KB Output is correct
55 Correct 14 ms 68368 KB Output is correct
56 Correct 8 ms 49888 KB Output is correct
57 Correct 15 ms 68292 KB Output is correct
58 Correct 9 ms 53852 KB Output is correct
59 Correct 65 ms 140484 KB Output is correct
60 Correct 38 ms 117356 KB Output is correct
61 Correct 63 ms 140380 KB Output is correct
62 Correct 35 ms 115536 KB Output is correct
63 Correct 63 ms 140584 KB Output is correct
64 Correct 36 ms 117584 KB Output is correct
65 Correct 49 ms 133508 KB Output is correct
66 Correct 47 ms 129884 KB Output is correct
67 Correct 41 ms 125800 KB Output is correct
68 Correct 39 ms 121692 KB Output is correct
69 Correct 47 ms 132956 KB Output is correct
70 Correct 46 ms 130372 KB Output is correct
71 Correct 48 ms 131024 KB Output is correct
72 Correct 48 ms 131676 KB Output is correct
73 Correct 41 ms 127720 KB Output is correct
74 Correct 41 ms 123740 KB Output is correct
75 Correct 46 ms 129884 KB Output is correct
76 Correct 52 ms 137540 KB Output is correct
77 Correct 51 ms 137544 KB Output is correct
78 Correct 41 ms 121684 KB Output is correct
79 Correct 40 ms 123720 KB Output is correct
80 Correct 58 ms 135884 KB Output is correct
81 Correct 40 ms 125788 KB Output is correct
82 Correct 43 ms 127296 KB Output is correct
83 Correct 57 ms 140372 KB Output is correct
84 Correct 45 ms 130012 KB Output is correct
85 Correct 52 ms 135332 KB Output is correct
86 Correct 53 ms 133972 KB Output is correct
87 Correct 46 ms 128740 KB Output is correct
88 Correct 55 ms 140880 KB Output is correct
89 Correct 56 ms 140784 KB Output is correct
90 Correct 44 ms 129372 KB Output is correct
91 Correct 57 ms 140892 KB Output is correct
92 Correct 55 ms 140808 KB Output is correct
93 Correct 55 ms 139600 KB Output is correct