Submission #752160

# Submission time Handle Problem Language Result Execution time Memory
752160 2023-06-02T11:31:39 Z Kihihihi Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
153 ms 135268 KB
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <ctime>
#include <chrono>
#include <cstdio>
#include <random>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <queue>
#include <bitset>
#include <list>
#include <fstream>
#include <functional>
#include <complex>
using namespace std;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

short skip_cin = 0;
const long long INF = 1e18, MOD = 1e9 + 7, MOD2 = 998244353, LOG = 18;
const long double EPS = 1e-9, PI = acos(-1);

const long long N = 205;

long long n, l;
vector<long long> x, t;

long long dp[N][N][N][2];

void solve()
{
    for (long long left = 0; left < N; left++)
    {
        for (long long right = 0; right < N; right++)
        {
            for (long long hv = 0; hv < N; hv++)
            {
                for (long long lr = 0; lr < 2; lr++)
                {
                    dp[left][right][hv][lr] = INF;
                }
            }
        }
    }

    cin >> n >> l;
    x.resize(n + 2);
    x[0] = 0;
    for (long long i = 1; i < n + 1; i++)
    {
        cin >> x[i];
    }
    x[n + 1] = l;
    t.resize(n + 2);
    t[0] = INF;
    for (long long i = 1; i < n + 1; i++)
    {
        cin >> t[i];
    }
    t[n + 1] = INF;
    n += 2;

    dp[1][1][2][0] = 0;
    for (long long sum = 2; sum < n; sum++)
    {
        for (long long left = 1; left < n + 1; left++)
        {
            long long right = sum - left;
            long long lidx = left - 1, ridx = n - right;
            if (right <= 0)
            {
                break;
            }

            for (long long hv = 2; hv < left + right + 1; hv++)
            {
                long long tol = x[lidx + 1] - x[lidx];
                long long add = (dp[left][right][hv][0] + tol <= t[lidx + 1]);
                dp[left + 1][right][hv + add][0] = min(dp[left + 1][right][hv + add][0], dp[left][right][hv][0] + tol);

                long long tor = l - (x[ridx - 1] - x[lidx]);
                add = (dp[left][right][hv][0] + tor <= t[ridx - 1]);
                dp[left][right + 1][hv + add][1] = min(dp[left][right + 1][hv + add][1], dp[left][right][hv][0] + tor);

                tor = x[ridx] - x[ridx - 1];
                add = (dp[left][right][hv][1] + tor <= t[ridx - 1]);
                dp[left][right + 1][hv + add][1] = min(dp[left][right + 1][hv + add][1], dp[left][right][hv][1] + tor);

                tol = l - (x[ridx] - x[lidx + 1]);
                add = (dp[left][right][hv][1] + tol <= t[lidx + 1]);
                dp[left + 1][right][hv + add][0] = min(dp[left + 1][right][hv + add][0], dp[left][right][hv][1] + tol);
            }
        }
    }

    long long ans = 0;
    for (long long left = 0; left < n + 1; left++)
    {
        for (long long right = 0; right < n + 1; right++)
        {
            for (long long hv = 0; hv < n + 1; hv++)
            {
                for (long long lr = 0; lr < 2; lr++)
                {
                    if (dp[left][right][hv][lr] != INF)
                    {
                        ans = max(ans, hv);
                    }
                }
            }
        }
    }
    ans -= 2;
    cout << ans << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    srand(time(NULL));

    int tst = 1;
    //cin >> tst;
    while (tst--)
    {
        solve();
    }

    return 0;
}

/*
<3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠤⠖⠚⢉⣩⣭⡭⠛⠓⠲⠦⣄⡀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢀⡴⠋⠁⠀⠀⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠳⢦⡀⠀⠀⠀⠀
⠀⠀⠀⠀⢀⡴⠃⢀⡴⢳⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣆⠀⠀⠀
⠀⠀⠀⠀⡾⠁⣠⠋⠀⠈⢧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢧⠀⠀
⠀⠀⠀⣸⠁⢰⠃⠀⠀⠀⠈⢣⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣇⠀
⠀⠀⠀⡇⠀⡾⡀⠀⠀⠀⠀⣀⣹⣆⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⠀
⠀⠀⢸⠃⢀⣇⡈⠀⠀⠀⠀⠀⠀⢀⡑⢄⡀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇
⠀⠀⢸⠀⢻⡟⡻⢶⡆⠀⠀⠀⠀⡼⠟⡳⢿⣦⡑⢄⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇
⠀⠀⣸⠀⢸⠃⡇⢀⠇⠀⠀⠀⠀⠀⡼⠀⠀⠈⣿⡗⠂⠀⠀⠀⠀⠀⠀⠀⢸⠁
⠀⠀⡏⠀⣼⠀⢳⠊⠀⠀⠀⠀⠀⠀⠱⣀⣀⠔⣸⠁⠀⠀⠀⠀⠀⠀⠀⢠⡟⠀
⠀⠀⡇⢀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⢸⠃⠀
⠀⢸⠃⠘⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠁⠀⠀⢀⠀⠀⠀⠀⠀⣾⠀⠀
⠀⣸⠀⠀⠹⡄⠀⠀⠈⠁⠀⠀⠀⠀⠀⠀⠀⡞⠀⠀⠀⠸⠀⠀⠀⠀⠀⡇⠀⠀
⠀⡏⠀⠀⠀⠙⣆⠀⠀⠀⠀⠀⠀⠀⢀⣠⢶⡇⠀⠀⢰⡀⠀⠀⠀⠀⠀⡇⠀⠀
⢰⠇⡄⠀⠀⠀⡿⢣⣀⣀⣀⡤⠴⡞⠉⠀⢸⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⣧⠀⠀
⣸⠀⡇⠀⠀⠀⠀⠀⠀⠉⠀⠀⠀⢹⠀⠀⢸⠀⠀⢀⣿⠇⠀⠀⠀⠁⠀⢸⠀⠀
⣿⠀⡇⠀⠀⠀⠀⠀⢀⡤⠤⠶⠶⠾⠤⠄⢸⠀⡀⠸⣿⣀⠀⠀⠀⠀⠀⠈⣇⠀
⡇⠀⡇⠀⠀⡀⠀⡴⠋⠀⠀⠀⠀⠀⠀⠀⠸⡌⣵⡀⢳⡇⠀⠀⠀⠀⠀⠀⢹⡀
⡇⠀⠇⠀⠀⡇⡸⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠮⢧⣀⣻⢂⠀⠀⠀⠀⠀⠀⢧
⣇⠀⢠⠀⠀⢳⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⡎⣆⠀⠀⠀⠀⠀⠘
⢻⠀⠈⠰⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰⠘⢮⣧⡀⠀⠀⠀⠀
⠸⡆⠀⠀⠇⣾⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠆⠀⠀⠀⠀⠀⠀⠀⠙⠳⣄⡀⢢⡀
<3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3
*/
# Verdict Execution time Memory Grader output
1 Correct 56 ms 135116 KB Output is correct
2 Correct 58 ms 135176 KB Output is correct
3 Correct 64 ms 135176 KB Output is correct
4 Correct 65 ms 135136 KB Output is correct
5 Correct 57 ms 135176 KB Output is correct
6 Correct 64 ms 135168 KB Output is correct
7 Correct 58 ms 135116 KB Output is correct
8 Correct 56 ms 135056 KB Output is correct
9 Correct 58 ms 135116 KB Output is correct
10 Correct 56 ms 135092 KB Output is correct
11 Correct 58 ms 135080 KB Output is correct
12 Correct 62 ms 135148 KB Output is correct
13 Correct 69 ms 135120 KB Output is correct
14 Correct 68 ms 135092 KB Output is correct
15 Correct 58 ms 135176 KB Output is correct
16 Correct 67 ms 135192 KB Output is correct
17 Correct 59 ms 135068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 135116 KB Output is correct
2 Correct 58 ms 135176 KB Output is correct
3 Correct 64 ms 135176 KB Output is correct
4 Correct 65 ms 135136 KB Output is correct
5 Correct 57 ms 135176 KB Output is correct
6 Correct 64 ms 135168 KB Output is correct
7 Correct 58 ms 135116 KB Output is correct
8 Correct 56 ms 135056 KB Output is correct
9 Correct 58 ms 135116 KB Output is correct
10 Correct 56 ms 135092 KB Output is correct
11 Correct 58 ms 135080 KB Output is correct
12 Correct 62 ms 135148 KB Output is correct
13 Correct 69 ms 135120 KB Output is correct
14 Correct 68 ms 135092 KB Output is correct
15 Correct 58 ms 135176 KB Output is correct
16 Correct 67 ms 135192 KB Output is correct
17 Correct 59 ms 135068 KB Output is correct
18 Correct 58 ms 135124 KB Output is correct
19 Correct 56 ms 135188 KB Output is correct
20 Correct 56 ms 135124 KB Output is correct
21 Correct 63 ms 135116 KB Output is correct
22 Correct 61 ms 135180 KB Output is correct
23 Correct 57 ms 135064 KB Output is correct
24 Correct 56 ms 135096 KB Output is correct
25 Correct 57 ms 135084 KB Output is correct
26 Correct 61 ms 135116 KB Output is correct
27 Correct 65 ms 135136 KB Output is correct
28 Correct 65 ms 135116 KB Output is correct
29 Correct 58 ms 135116 KB Output is correct
30 Correct 58 ms 135060 KB Output is correct
31 Correct 60 ms 135180 KB Output is correct
32 Correct 57 ms 135136 KB Output is correct
33 Correct 57 ms 135144 KB Output is correct
34 Correct 57 ms 135116 KB Output is correct
35 Correct 72 ms 135176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 135116 KB Output is correct
2 Correct 58 ms 135176 KB Output is correct
3 Correct 64 ms 135176 KB Output is correct
4 Correct 65 ms 135136 KB Output is correct
5 Correct 57 ms 135176 KB Output is correct
6 Correct 64 ms 135168 KB Output is correct
7 Correct 58 ms 135116 KB Output is correct
8 Correct 56 ms 135056 KB Output is correct
9 Correct 58 ms 135116 KB Output is correct
10 Correct 56 ms 135092 KB Output is correct
11 Correct 58 ms 135080 KB Output is correct
12 Correct 62 ms 135148 KB Output is correct
13 Correct 69 ms 135120 KB Output is correct
14 Correct 68 ms 135092 KB Output is correct
15 Correct 58 ms 135176 KB Output is correct
16 Correct 67 ms 135192 KB Output is correct
17 Correct 59 ms 135068 KB Output is correct
18 Correct 134 ms 135184 KB Output is correct
19 Correct 89 ms 135164 KB Output is correct
20 Correct 69 ms 135056 KB Output is correct
21 Correct 87 ms 135124 KB Output is correct
22 Correct 99 ms 135196 KB Output is correct
23 Correct 67 ms 135180 KB Output is correct
24 Correct 65 ms 135136 KB Output is correct
25 Correct 73 ms 135116 KB Output is correct
26 Correct 70 ms 135140 KB Output is correct
27 Correct 71 ms 135108 KB Output is correct
28 Correct 62 ms 135184 KB Output is correct
29 Correct 68 ms 135072 KB Output is correct
30 Correct 65 ms 135184 KB Output is correct
31 Correct 71 ms 135148 KB Output is correct
32 Correct 71 ms 135152 KB Output is correct
33 Correct 67 ms 135112 KB Output is correct
34 Correct 61 ms 135172 KB Output is correct
35 Correct 68 ms 135084 KB Output is correct
36 Correct 61 ms 135180 KB Output is correct
37 Correct 71 ms 135060 KB Output is correct
38 Correct 59 ms 135084 KB Output is correct
39 Correct 69 ms 135172 KB Output is correct
40 Correct 62 ms 135136 KB Output is correct
41 Correct 153 ms 135116 KB Output is correct
42 Correct 117 ms 135140 KB Output is correct
43 Correct 143 ms 135184 KB Output is correct
44 Correct 113 ms 135108 KB Output is correct
45 Correct 149 ms 135180 KB Output is correct
46 Correct 103 ms 135140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 135116 KB Output is correct
2 Correct 58 ms 135176 KB Output is correct
3 Correct 64 ms 135176 KB Output is correct
4 Correct 65 ms 135136 KB Output is correct
5 Correct 57 ms 135176 KB Output is correct
6 Correct 64 ms 135168 KB Output is correct
7 Correct 58 ms 135116 KB Output is correct
8 Correct 56 ms 135056 KB Output is correct
9 Correct 58 ms 135116 KB Output is correct
10 Correct 56 ms 135092 KB Output is correct
11 Correct 58 ms 135080 KB Output is correct
12 Correct 62 ms 135148 KB Output is correct
13 Correct 69 ms 135120 KB Output is correct
14 Correct 68 ms 135092 KB Output is correct
15 Correct 58 ms 135176 KB Output is correct
16 Correct 67 ms 135192 KB Output is correct
17 Correct 59 ms 135068 KB Output is correct
18 Correct 58 ms 135124 KB Output is correct
19 Correct 56 ms 135188 KB Output is correct
20 Correct 56 ms 135124 KB Output is correct
21 Correct 63 ms 135116 KB Output is correct
22 Correct 61 ms 135180 KB Output is correct
23 Correct 57 ms 135064 KB Output is correct
24 Correct 56 ms 135096 KB Output is correct
25 Correct 57 ms 135084 KB Output is correct
26 Correct 61 ms 135116 KB Output is correct
27 Correct 65 ms 135136 KB Output is correct
28 Correct 65 ms 135116 KB Output is correct
29 Correct 58 ms 135116 KB Output is correct
30 Correct 58 ms 135060 KB Output is correct
31 Correct 60 ms 135180 KB Output is correct
32 Correct 57 ms 135136 KB Output is correct
33 Correct 57 ms 135144 KB Output is correct
34 Correct 57 ms 135116 KB Output is correct
35 Correct 72 ms 135176 KB Output is correct
36 Correct 134 ms 135184 KB Output is correct
37 Correct 89 ms 135164 KB Output is correct
38 Correct 69 ms 135056 KB Output is correct
39 Correct 87 ms 135124 KB Output is correct
40 Correct 99 ms 135196 KB Output is correct
41 Correct 67 ms 135180 KB Output is correct
42 Correct 65 ms 135136 KB Output is correct
43 Correct 73 ms 135116 KB Output is correct
44 Correct 70 ms 135140 KB Output is correct
45 Correct 71 ms 135108 KB Output is correct
46 Correct 62 ms 135184 KB Output is correct
47 Correct 68 ms 135072 KB Output is correct
48 Correct 65 ms 135184 KB Output is correct
49 Correct 71 ms 135148 KB Output is correct
50 Correct 71 ms 135152 KB Output is correct
51 Correct 67 ms 135112 KB Output is correct
52 Correct 61 ms 135172 KB Output is correct
53 Correct 68 ms 135084 KB Output is correct
54 Correct 61 ms 135180 KB Output is correct
55 Correct 71 ms 135060 KB Output is correct
56 Correct 59 ms 135084 KB Output is correct
57 Correct 69 ms 135172 KB Output is correct
58 Correct 62 ms 135136 KB Output is correct
59 Correct 153 ms 135116 KB Output is correct
60 Correct 117 ms 135140 KB Output is correct
61 Correct 143 ms 135184 KB Output is correct
62 Correct 113 ms 135108 KB Output is correct
63 Correct 149 ms 135180 KB Output is correct
64 Correct 103 ms 135140 KB Output is correct
65 Correct 139 ms 135188 KB Output is correct
66 Correct 139 ms 135116 KB Output is correct
67 Correct 115 ms 135084 KB Output is correct
68 Correct 114 ms 135132 KB Output is correct
69 Correct 142 ms 135236 KB Output is correct
70 Correct 127 ms 135096 KB Output is correct
71 Correct 129 ms 135268 KB Output is correct
72 Correct 132 ms 135144 KB Output is correct
73 Correct 125 ms 135244 KB Output is correct
74 Correct 116 ms 135116 KB Output is correct
75 Correct 125 ms 135184 KB Output is correct
76 Correct 142 ms 135072 KB Output is correct
77 Correct 136 ms 135184 KB Output is correct
78 Correct 119 ms 135188 KB Output is correct
79 Correct 121 ms 135116 KB Output is correct
80 Correct 139 ms 135080 KB Output is correct
81 Correct 119 ms 135184 KB Output is correct
82 Correct 122 ms 135184 KB Output is correct
83 Correct 142 ms 135076 KB Output is correct
84 Correct 126 ms 135112 KB Output is correct
85 Correct 129 ms 135188 KB Output is correct
86 Correct 131 ms 135192 KB Output is correct
87 Correct 130 ms 135108 KB Output is correct
88 Correct 146 ms 135184 KB Output is correct
89 Correct 147 ms 135188 KB Output is correct
90 Correct 133 ms 135220 KB Output is correct
91 Correct 146 ms 135116 KB Output is correct
92 Correct 142 ms 135080 KB Output is correct
93 Correct 148 ms 135180 KB Output is correct