Submission #232913

# Submission time Handle Problem Language Result Execution time Memory
232913 2020-05-18T16:27:42 Z andreiomd Bali Sculptures (APIO15_sculpture) C++11
71 / 100
24 ms 512 KB
#include <iostream>

using namespace std;

const int NMAX = 2e3 + 5;

int N, A, B, Y[NMAX];

long long sp[NMAX], BitMask;

static inline void Read ()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N >> A >> B;

    for(int i = 1; i <= N; ++i)
        cin >> Y[i], sp[i] = sp[i - 1] + 1LL * Y[i];

    return;
}

auto Check = [] (int byte, long long Sum)
{
    if(Sum & (1LL << byte))
        return 0;

    Sum >>= (1LL * (byte + 1));

    if((Sum | BitMask) != BitMask)
        return 0;

    return 1;
};

static inline bool Ok (int byte)
{
    bool dp[N + 1][N + 1];
    for(int i = 0; i <= N; ++i)
        for(int j = 0; j <= N; ++j)
            dp[i][j] = 0;

    dp[0][0] = 1;

    for(int i = 1; i <= N; ++i)
        for(int j = 1; j <= i; ++j)
            for(int k = 0; k < i && !dp[i][j]; ++k)
                if(dp[k][j - 1] && Check(byte, sp[i] - sp[k]))
                    dp[i][j] = 1;

    for(int i = A; i <= B; ++i)
        if(dp[N][i])
            return 1;

    return 0;
}

static inline void Solve_1 ()
{
    long long ans = 0;

    for(int i = 40; i >= 0; --i)
    {
        bool Now = Ok(i);
        BitMask = (BitMask << 1LL);

        if(Now)
            continue;
        else
            ans += 1LL * (1LL << i), ++BitMask;
    }

    cout << ans << '\n';

    return;
}

static inline void Solve ()
{
    if(N <= 1e2)
        Solve_1();

    return;
}

int main()
{
    Read();

    Solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 6 ms 384 KB Output is correct
33 Correct 6 ms 384 KB Output is correct
34 Correct 6 ms 384 KB Output is correct
35 Correct 6 ms 384 KB Output is correct
36 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 6 ms 384 KB Output is correct
23 Correct 6 ms 384 KB Output is correct
24 Correct 6 ms 384 KB Output is correct
25 Correct 8 ms 384 KB Output is correct
26 Correct 11 ms 384 KB Output is correct
27 Correct 13 ms 512 KB Output is correct
28 Correct 16 ms 384 KB Output is correct
29 Correct 16 ms 384 KB Output is correct
30 Correct 15 ms 384 KB Output is correct
31 Correct 16 ms 384 KB Output is correct
32 Correct 17 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 5 ms 384 KB Output is correct
40 Correct 6 ms 384 KB Output is correct
41 Correct 6 ms 384 KB Output is correct
42 Correct 7 ms 384 KB Output is correct
43 Correct 7 ms 288 KB Output is correct
44 Correct 6 ms 384 KB Output is correct
45 Correct 6 ms 384 KB Output is correct
46 Correct 7 ms 384 KB Output is correct
47 Correct 6 ms 384 KB Output is correct
48 Correct 8 ms 384 KB Output is correct
49 Correct 11 ms 384 KB Output is correct
50 Correct 14 ms 384 KB Output is correct
51 Correct 17 ms 384 KB Output is correct
52 Correct 17 ms 384 KB Output is correct
53 Correct 15 ms 384 KB Output is correct
54 Correct 16 ms 384 KB Output is correct
55 Correct 17 ms 384 KB Output is correct
56 Correct 8 ms 384 KB Output is correct
57 Correct 14 ms 384 KB Output is correct
58 Correct 16 ms 384 KB Output is correct
59 Correct 20 ms 384 KB Output is correct
60 Correct 24 ms 384 KB Output is correct
61 Correct 20 ms 384 KB Output is correct
62 Correct 20 ms 384 KB Output is correct
63 Correct 22 ms 384 KB Output is correct
64 Correct 13 ms 384 KB Output is correct
65 Correct 8 ms 384 KB Output is correct
66 Correct 10 ms 384 KB Output is correct
67 Correct 14 ms 384 KB Output is correct
68 Correct 17 ms 384 KB Output is correct
69 Correct 20 ms 384 KB Output is correct
70 Correct 21 ms 384 KB Output is correct
71 Correct 19 ms 384 KB Output is correct
72 Correct 20 ms 384 KB Output is correct
73 Correct 21 ms 384 KB Output is correct
74 Correct 23 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 6 ms 384 KB Output is correct
29 Correct 6 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 6 ms 384 KB Output is correct
33 Correct 6 ms 384 KB Output is correct
34 Correct 7 ms 384 KB Output is correct
35 Correct 8 ms 384 KB Output is correct
36 Correct 10 ms 384 KB Output is correct
37 Correct 13 ms 384 KB Output is correct
38 Correct 16 ms 384 KB Output is correct
39 Correct 17 ms 384 KB Output is correct
40 Correct 16 ms 384 KB Output is correct
41 Correct 17 ms 384 KB Output is correct
42 Correct 16 ms 384 KB Output is correct
43 Correct 7 ms 384 KB Output is correct
44 Correct 14 ms 384 KB Output is correct
45 Correct 17 ms 384 KB Output is correct
46 Correct 19 ms 384 KB Output is correct
47 Correct 21 ms 384 KB Output is correct
48 Correct 19 ms 384 KB Output is correct
49 Correct 20 ms 384 KB Output is correct
50 Correct 22 ms 384 KB Output is correct
51 Incorrect 4 ms 384 KB Output isn't correct
52 Halted 0 ms 0 KB -