답안 #808729

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
808729 2023-08-05T10:08:47 Z finn__ Tortoise (CEOI21_tortoise) C++17
18 / 100
16 ms 1036 KB
#include <bits/stdc++.h>
using namespace std;

constexpr size_t N = 300;

int32_t f[(N << 1) - 1][N], a[N], x[N], u[N], v[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    size_t n, m = 0, last_playground = -1;
    cin >> n;

    int32_t sum_a = 0;
    for (size_t i = 0; i < n; ++i)
    {
        cin >> a[i];
        if (a[i] > 0)
            x[m] = i, u[m] = last_playground, sum_a += a[i], ++m;
        else if (a[i] == -1)
            last_playground = i;
    }

    last_playground = n;
    for (size_t i = n - 1, j = m - 1; i < n; --i)
    {
        if (a[i] > 0)
            v[j] = last_playground, --j;
        else if (a[i] == -1)
            last_playground = i;
    }

    for (size_t i = 0; i < (N << 1) - 1; ++i)
        fill(f[i], f[i] + N, INT32_MIN);
    for (size_t i = 0; i < m; ++i)
        f[x[i]][i] = 0;

    int32_t ans = 0;
    for (size_t i = 0; i < (n << 1) - 1; ++i)
        for (size_t j = 0; j < m; ++j)
        {
            ans = max(ans, f[i][j] + ((int32_t)i <= (x[j] << 1)));
            for (size_t k = j + 1; k < m; ++k)
            {
                // Bring the candy of the j-th shop to the preceding playground.
                if ((int32_t)i <= (x[j] << 1) && u[j] != -1 && (int32_t)i + x[j] + x[k] - (u[j] << 1) < (int32_t)(n << 1) - 1)
                    f[(int32_t)i + x[j] + x[k] - (u[j] << 1)][k] = max(f[(int32_t)i + x[j] + x[k] - (u[j] << 1)][k], f[i][j] + 1);
                // Bring the candy of the j-th shop to the next playground.
                if ((int32_t)i <= (x[j] << 1) && v[j] != (int32_t)n && (int32_t)i + v[j] - x[j] + abs(x[k] - v[j]) < (int32_t)(n << 1) - 1)
                    f[(int32_t)i + v[j] - x[j] + abs(x[k] - v[j])][k] = max(f[(int32_t)i + v[j] - x[j] + abs(x[k] - v[j])][k], f[i][j] + 1);
            }
        }

    cout << sum_a - ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 1 ms 980 KB Output is correct
12 Correct 1 ms 968 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 1 ms 980 KB Output is correct
15 Correct 1 ms 964 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 980 KB Output is correct
18 Correct 1 ms 980 KB Output is correct
19 Correct 1 ms 968 KB Output is correct
20 Correct 1 ms 980 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 980 KB Output is correct
23 Correct 1 ms 980 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 980 KB Output is correct
26 Correct 1 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 1 ms 980 KB Output is correct
12 Correct 1 ms 968 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 1 ms 980 KB Output is correct
15 Correct 1 ms 964 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 980 KB Output is correct
18 Correct 1 ms 980 KB Output is correct
19 Correct 1 ms 968 KB Output is correct
20 Correct 1 ms 980 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 980 KB Output is correct
23 Correct 1 ms 980 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 980 KB Output is correct
26 Correct 1 ms 980 KB Output is correct
27 Correct 7 ms 1032 KB Output is correct
28 Correct 16 ms 980 KB Output is correct
29 Correct 10 ms 980 KB Output is correct
30 Correct 7 ms 1032 KB Output is correct
31 Correct 7 ms 980 KB Output is correct
32 Correct 5 ms 980 KB Output is correct
33 Correct 8 ms 1036 KB Output is correct
34 Correct 10 ms 980 KB Output is correct
35 Correct 7 ms 980 KB Output is correct
36 Correct 6 ms 972 KB Output is correct
37 Correct 8 ms 1032 KB Output is correct
38 Correct 6 ms 968 KB Output is correct
39 Correct 6 ms 980 KB Output is correct
40 Correct 5 ms 980 KB Output is correct
41 Correct 6 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 1 ms 980 KB Output is correct
12 Correct 1 ms 968 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 1 ms 980 KB Output is correct
15 Correct 1 ms 964 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 980 KB Output is correct
18 Correct 1 ms 980 KB Output is correct
19 Correct 1 ms 968 KB Output is correct
20 Correct 1 ms 980 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 980 KB Output is correct
23 Correct 1 ms 980 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 980 KB Output is correct
26 Correct 1 ms 980 KB Output is correct
27 Correct 7 ms 1032 KB Output is correct
28 Correct 16 ms 980 KB Output is correct
29 Correct 10 ms 980 KB Output is correct
30 Correct 7 ms 1032 KB Output is correct
31 Correct 7 ms 980 KB Output is correct
32 Correct 5 ms 980 KB Output is correct
33 Correct 8 ms 1036 KB Output is correct
34 Correct 10 ms 980 KB Output is correct
35 Correct 7 ms 980 KB Output is correct
36 Correct 6 ms 972 KB Output is correct
37 Correct 8 ms 1032 KB Output is correct
38 Correct 6 ms 968 KB Output is correct
39 Correct 6 ms 980 KB Output is correct
40 Correct 5 ms 980 KB Output is correct
41 Correct 6 ms 980 KB Output is correct
42 Incorrect 1 ms 972 KB Output isn't correct
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 1 ms 980 KB Output is correct
12 Correct 1 ms 968 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 1 ms 980 KB Output is correct
15 Correct 1 ms 964 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 980 KB Output is correct
18 Correct 1 ms 980 KB Output is correct
19 Correct 1 ms 968 KB Output is correct
20 Correct 1 ms 980 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 980 KB Output is correct
23 Correct 1 ms 980 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 980 KB Output is correct
26 Correct 1 ms 980 KB Output is correct
27 Correct 7 ms 1032 KB Output is correct
28 Correct 16 ms 980 KB Output is correct
29 Correct 10 ms 980 KB Output is correct
30 Correct 7 ms 1032 KB Output is correct
31 Correct 7 ms 980 KB Output is correct
32 Correct 5 ms 980 KB Output is correct
33 Correct 8 ms 1036 KB Output is correct
34 Correct 10 ms 980 KB Output is correct
35 Correct 7 ms 980 KB Output is correct
36 Correct 6 ms 972 KB Output is correct
37 Correct 8 ms 1032 KB Output is correct
38 Correct 6 ms 968 KB Output is correct
39 Correct 6 ms 980 KB Output is correct
40 Correct 5 ms 980 KB Output is correct
41 Correct 6 ms 980 KB Output is correct
42 Incorrect 1 ms 972 KB Output isn't correct
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 1 ms 980 KB Output is correct
12 Correct 1 ms 968 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 1 ms 980 KB Output is correct
15 Correct 1 ms 964 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 980 KB Output is correct
18 Correct 1 ms 980 KB Output is correct
19 Correct 1 ms 968 KB Output is correct
20 Correct 1 ms 980 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 980 KB Output is correct
23 Correct 1 ms 980 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 980 KB Output is correct
26 Correct 1 ms 980 KB Output is correct
27 Correct 7 ms 1032 KB Output is correct
28 Correct 16 ms 980 KB Output is correct
29 Correct 10 ms 980 KB Output is correct
30 Correct 7 ms 1032 KB Output is correct
31 Correct 7 ms 980 KB Output is correct
32 Correct 5 ms 980 KB Output is correct
33 Correct 8 ms 1036 KB Output is correct
34 Correct 10 ms 980 KB Output is correct
35 Correct 7 ms 980 KB Output is correct
36 Correct 6 ms 972 KB Output is correct
37 Correct 8 ms 1032 KB Output is correct
38 Correct 6 ms 968 KB Output is correct
39 Correct 6 ms 980 KB Output is correct
40 Correct 5 ms 980 KB Output is correct
41 Correct 6 ms 980 KB Output is correct
42 Incorrect 1 ms 972 KB Output isn't correct
43 Halted 0 ms 0 KB -