답안 #364263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
364263 2021-02-08T16:20:45 Z Lam_lai_cuoc_doi Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
151 ms 135424 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

const bool typetest = 0;
const int N = 2e2 + 5;
const ll Inf = 1e17;
int n;
ll x[N], y[N], t[N];
ll dp[N][N][N][2], l;
int ans(0);

void Read()
{
    cin >> n >> l;
    t[0] = -1;
    for (int i = 1; i <= n; ++i)
    {
        cin >> x[i];
        y[i] = l - x[i];
    }
    for (int i = 1; i <= n; ++i)
        cin >> t[i];
}

int pos(int v)
{
    v += n + 1;
    if (v >= n + 1)
        v -= n + 1;
    if (v >= n + 1)
        v -= n + 1;
    return v;
}

template <class T>
inline void Min(T &x, T y)
{
    if (x > y)
        x = y;
}

void Solve()
{
    fill_n(&dp[0][0][0][0], N * N * N * 2, Inf);
    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)
            for (int h = 0; h <= i; ++h)
            {
                if (dp[j][pos(j + i)][h][0] != Inf)
                {
                    ans = max(ans, h);
                    ll v = dp[j][pos(j + i)][h][0] + y[pos(j - 1)] - y[j];
                    Min(dp[pos(j - 1)][pos(j + i)][h + (v <= t[pos(j - 1)])][0], v);
                    v = dp[j][pos(j + i)][h][0] + y[j] + x[pos(j + i + 1)];
                    Min(dp[j][pos(j + i + 1)][h + (v <= t[pos(j + i + 1)])][1], v);
                }
                if (dp[j][(j + i) % (n + 1)][h][1] != Inf)
                {
                    ans = max(ans, h);
                    ll v = dp[j][pos(j + i)][h][1] + x[pos(j + i + 1)] - x[pos(j + i)];
                    Min(dp[j][pos(j + i + 1)][h + (v <= t[pos(j + i + 1)])][1], v);
                    v = dp[j][pos(j + i)][h][1] + x[pos(j + i)] + y[pos(j - 1)];
                    Min(dp[pos(j - 1)][pos(j + i)][h + (v <= t[pos(j - 1)])][0], v);
                }
            }
    cout << ans;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t(1);
    if (typetest)
        cin >> t;
    for (int _ = 1; _ <= t; ++_)
    {
        Read();
        Solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 135148 KB Output is correct
2 Correct 74 ms 135276 KB Output is correct
3 Correct 73 ms 135276 KB Output is correct
4 Correct 74 ms 135148 KB Output is correct
5 Correct 80 ms 135276 KB Output is correct
6 Correct 73 ms 135148 KB Output is correct
7 Correct 76 ms 135276 KB Output is correct
8 Correct 73 ms 135276 KB Output is correct
9 Correct 74 ms 135148 KB Output is correct
10 Correct 75 ms 135148 KB Output is correct
11 Correct 73 ms 135148 KB Output is correct
12 Correct 74 ms 135148 KB Output is correct
13 Correct 73 ms 135148 KB Output is correct
14 Correct 74 ms 135296 KB Output is correct
15 Correct 74 ms 135148 KB Output is correct
16 Correct 74 ms 135276 KB Output is correct
17 Correct 77 ms 135276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 135148 KB Output is correct
2 Correct 74 ms 135276 KB Output is correct
3 Correct 73 ms 135276 KB Output is correct
4 Correct 74 ms 135148 KB Output is correct
5 Correct 80 ms 135276 KB Output is correct
6 Correct 73 ms 135148 KB Output is correct
7 Correct 76 ms 135276 KB Output is correct
8 Correct 73 ms 135276 KB Output is correct
9 Correct 74 ms 135148 KB Output is correct
10 Correct 75 ms 135148 KB Output is correct
11 Correct 73 ms 135148 KB Output is correct
12 Correct 74 ms 135148 KB Output is correct
13 Correct 73 ms 135148 KB Output is correct
14 Correct 74 ms 135296 KB Output is correct
15 Correct 74 ms 135148 KB Output is correct
16 Correct 74 ms 135276 KB Output is correct
17 Correct 77 ms 135276 KB Output is correct
18 Correct 77 ms 135296 KB Output is correct
19 Correct 75 ms 135148 KB Output is correct
20 Correct 73 ms 135276 KB Output is correct
21 Correct 75 ms 135276 KB Output is correct
22 Correct 74 ms 135148 KB Output is correct
23 Correct 75 ms 135404 KB Output is correct
24 Correct 75 ms 135148 KB Output is correct
25 Correct 74 ms 135276 KB Output is correct
26 Correct 76 ms 135148 KB Output is correct
27 Correct 76 ms 135148 KB Output is correct
28 Correct 73 ms 135404 KB Output is correct
29 Correct 75 ms 135148 KB Output is correct
30 Correct 74 ms 135148 KB Output is correct
31 Correct 74 ms 135276 KB Output is correct
32 Correct 73 ms 135148 KB Output is correct
33 Correct 74 ms 135148 KB Output is correct
34 Correct 75 ms 135148 KB Output is correct
35 Correct 75 ms 135148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 135148 KB Output is correct
2 Correct 74 ms 135276 KB Output is correct
3 Correct 73 ms 135276 KB Output is correct
4 Correct 74 ms 135148 KB Output is correct
5 Correct 80 ms 135276 KB Output is correct
6 Correct 73 ms 135148 KB Output is correct
7 Correct 76 ms 135276 KB Output is correct
8 Correct 73 ms 135276 KB Output is correct
9 Correct 74 ms 135148 KB Output is correct
10 Correct 75 ms 135148 KB Output is correct
11 Correct 73 ms 135148 KB Output is correct
12 Correct 74 ms 135148 KB Output is correct
13 Correct 73 ms 135148 KB Output is correct
14 Correct 74 ms 135296 KB Output is correct
15 Correct 74 ms 135148 KB Output is correct
16 Correct 74 ms 135276 KB Output is correct
17 Correct 77 ms 135276 KB Output is correct
18 Correct 116 ms 135148 KB Output is correct
19 Correct 97 ms 135148 KB Output is correct
20 Correct 82 ms 135148 KB Output is correct
21 Correct 93 ms 135148 KB Output is correct
22 Correct 109 ms 135404 KB Output is correct
23 Correct 84 ms 135208 KB Output is correct
24 Correct 77 ms 135148 KB Output is correct
25 Correct 82 ms 135424 KB Output is correct
26 Correct 76 ms 135148 KB Output is correct
27 Correct 84 ms 135148 KB Output is correct
28 Correct 78 ms 135148 KB Output is correct
29 Correct 82 ms 135276 KB Output is correct
30 Correct 78 ms 135148 KB Output is correct
31 Correct 81 ms 135276 KB Output is correct
32 Correct 76 ms 135148 KB Output is correct
33 Correct 82 ms 135148 KB Output is correct
34 Correct 74 ms 135148 KB Output is correct
35 Correct 79 ms 135148 KB Output is correct
36 Correct 75 ms 135148 KB Output is correct
37 Correct 78 ms 135148 KB Output is correct
38 Correct 76 ms 135272 KB Output is correct
39 Correct 78 ms 135148 KB Output is correct
40 Correct 78 ms 135148 KB Output is correct
41 Correct 137 ms 135276 KB Output is correct
42 Correct 85 ms 135188 KB Output is correct
43 Correct 135 ms 135148 KB Output is correct
44 Correct 87 ms 135148 KB Output is correct
45 Correct 140 ms 135276 KB Output is correct
46 Correct 86 ms 135148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 135148 KB Output is correct
2 Correct 74 ms 135276 KB Output is correct
3 Correct 73 ms 135276 KB Output is correct
4 Correct 74 ms 135148 KB Output is correct
5 Correct 80 ms 135276 KB Output is correct
6 Correct 73 ms 135148 KB Output is correct
7 Correct 76 ms 135276 KB Output is correct
8 Correct 73 ms 135276 KB Output is correct
9 Correct 74 ms 135148 KB Output is correct
10 Correct 75 ms 135148 KB Output is correct
11 Correct 73 ms 135148 KB Output is correct
12 Correct 74 ms 135148 KB Output is correct
13 Correct 73 ms 135148 KB Output is correct
14 Correct 74 ms 135296 KB Output is correct
15 Correct 74 ms 135148 KB Output is correct
16 Correct 74 ms 135276 KB Output is correct
17 Correct 77 ms 135276 KB Output is correct
18 Correct 77 ms 135296 KB Output is correct
19 Correct 75 ms 135148 KB Output is correct
20 Correct 73 ms 135276 KB Output is correct
21 Correct 75 ms 135276 KB Output is correct
22 Correct 74 ms 135148 KB Output is correct
23 Correct 75 ms 135404 KB Output is correct
24 Correct 75 ms 135148 KB Output is correct
25 Correct 74 ms 135276 KB Output is correct
26 Correct 76 ms 135148 KB Output is correct
27 Correct 76 ms 135148 KB Output is correct
28 Correct 73 ms 135404 KB Output is correct
29 Correct 75 ms 135148 KB Output is correct
30 Correct 74 ms 135148 KB Output is correct
31 Correct 74 ms 135276 KB Output is correct
32 Correct 73 ms 135148 KB Output is correct
33 Correct 74 ms 135148 KB Output is correct
34 Correct 75 ms 135148 KB Output is correct
35 Correct 75 ms 135148 KB Output is correct
36 Correct 116 ms 135148 KB Output is correct
37 Correct 97 ms 135148 KB Output is correct
38 Correct 82 ms 135148 KB Output is correct
39 Correct 93 ms 135148 KB Output is correct
40 Correct 109 ms 135404 KB Output is correct
41 Correct 84 ms 135208 KB Output is correct
42 Correct 77 ms 135148 KB Output is correct
43 Correct 82 ms 135424 KB Output is correct
44 Correct 76 ms 135148 KB Output is correct
45 Correct 84 ms 135148 KB Output is correct
46 Correct 78 ms 135148 KB Output is correct
47 Correct 82 ms 135276 KB Output is correct
48 Correct 78 ms 135148 KB Output is correct
49 Correct 81 ms 135276 KB Output is correct
50 Correct 76 ms 135148 KB Output is correct
51 Correct 82 ms 135148 KB Output is correct
52 Correct 74 ms 135148 KB Output is correct
53 Correct 79 ms 135148 KB Output is correct
54 Correct 75 ms 135148 KB Output is correct
55 Correct 78 ms 135148 KB Output is correct
56 Correct 76 ms 135272 KB Output is correct
57 Correct 78 ms 135148 KB Output is correct
58 Correct 78 ms 135148 KB Output is correct
59 Correct 137 ms 135276 KB Output is correct
60 Correct 85 ms 135188 KB Output is correct
61 Correct 135 ms 135148 KB Output is correct
62 Correct 87 ms 135148 KB Output is correct
63 Correct 140 ms 135276 KB Output is correct
64 Correct 86 ms 135148 KB Output is correct
65 Correct 125 ms 135276 KB Output is correct
66 Correct 118 ms 135276 KB Output is correct
67 Correct 115 ms 135404 KB Output is correct
68 Correct 109 ms 135276 KB Output is correct
69 Correct 124 ms 135276 KB Output is correct
70 Correct 132 ms 135156 KB Output is correct
71 Correct 115 ms 135260 KB Output is correct
72 Correct 133 ms 135276 KB Output is correct
73 Correct 103 ms 135276 KB Output is correct
74 Correct 117 ms 135276 KB Output is correct
75 Correct 115 ms 135276 KB Output is correct
76 Correct 134 ms 135276 KB Output is correct
77 Correct 125 ms 135276 KB Output is correct
78 Correct 116 ms 135276 KB Output is correct
79 Correct 118 ms 135276 KB Output is correct
80 Correct 137 ms 135296 KB Output is correct
81 Correct 111 ms 135276 KB Output is correct
82 Correct 106 ms 135276 KB Output is correct
83 Correct 129 ms 135276 KB Output is correct
84 Correct 109 ms 135276 KB Output is correct
85 Correct 112 ms 135276 KB Output is correct
86 Correct 112 ms 135276 KB Output is correct
87 Correct 122 ms 135276 KB Output is correct
88 Correct 151 ms 135276 KB Output is correct
89 Correct 140 ms 135276 KB Output is correct
90 Correct 90 ms 135276 KB Output is correct
91 Correct 150 ms 135276 KB Output is correct
92 Correct 135 ms 135196 KB Output is correct
93 Correct 93 ms 135276 KB Output is correct