Submission #735162

# Submission time Handle Problem Language Result Execution time Memory
735162 2023-05-03T16:21:48 Z colossal_pepe Bali Sculptures (APIO15_sculpture) C++17
50 / 100
575 ms 16212 KB
#include <iostream>
#include <cstring>
using namespace std;

using ll = long long;

const int INF = 1e9;
const int N = 2000;

int n, a, b, dp[N + 5][N + 5];
ll x[N + 5];

bool isSubmask(ll sup, ll sub) {
    return (sup | sub) == sup;
}

int brutus(int l, int r, ll c) {
    if (r == n) return (isSubmask(c, x[r] - x[l - 1]) ? 0 : INF);
    if (dp[l][r] != -1) return dp[l][r];
    int &ret = dp[l][r];
    ret = brutus(l, r + 1, c);
    if (isSubmask(c, x[r] - x[l - 1])) ret = min(ret, 1 + brutus(r + 1, r + 1, c));
    // cout << l << ' ' << r << ' ' << ret << endl;
    return ret;
}

bool ok(ll target) {
    memset(dp, -1, sizeof dp);
    return 1 + brutus(1, 1, target) <= b;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> a >> b;
    x[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
        x[i] += x[i - 1];
    }
    ll c = (1ll << 42) - 1;
    for (ll bit = 41; bit >= 0; bit--) {
        c -= (1ll << bit);
        if (not ok(c)) c += (1ll << bit);
    }
    cout << c << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 73 ms 16036 KB Output is correct
2 Correct 73 ms 16036 KB Output is correct
3 Correct 73 ms 15956 KB Output is correct
4 Correct 72 ms 16036 KB Output is correct
5 Correct 74 ms 16040 KB Output is correct
6 Correct 76 ms 16032 KB Output is correct
7 Correct 75 ms 16036 KB Output is correct
8 Correct 73 ms 16036 KB Output is correct
9 Correct 76 ms 16044 KB Output is correct
10 Correct 76 ms 16040 KB Output is correct
11 Correct 85 ms 16036 KB Output is correct
12 Correct 83 ms 16040 KB Output is correct
13 Correct 75 ms 16044 KB Output is correct
14 Correct 72 ms 16040 KB Output is correct
15 Incorrect 75 ms 16040 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 16036 KB Output is correct
2 Correct 73 ms 16032 KB Output is correct
3 Correct 79 ms 15956 KB Output is correct
4 Correct 85 ms 15956 KB Output is correct
5 Correct 73 ms 16040 KB Output is correct
6 Correct 75 ms 16032 KB Output is correct
7 Correct 83 ms 15956 KB Output is correct
8 Correct 74 ms 16036 KB Output is correct
9 Correct 72 ms 16048 KB Output is correct
10 Correct 73 ms 15956 KB Output is correct
11 Correct 74 ms 16036 KB Output is correct
12 Correct 81 ms 16040 KB Output is correct
13 Correct 78 ms 16044 KB Output is correct
14 Correct 80 ms 15956 KB Output is correct
15 Incorrect 78 ms 16048 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 16040 KB Output is correct
2 Correct 78 ms 15952 KB Output is correct
3 Correct 83 ms 16036 KB Output is correct
4 Correct 83 ms 16040 KB Output is correct
5 Correct 73 ms 16048 KB Output is correct
6 Correct 72 ms 16040 KB Output is correct
7 Correct 72 ms 16084 KB Output is correct
8 Correct 82 ms 15956 KB Output is correct
9 Correct 86 ms 16036 KB Output is correct
10 Correct 83 ms 15956 KB Output is correct
11 Correct 81 ms 15956 KB Output is correct
12 Correct 88 ms 16036 KB Output is correct
13 Correct 96 ms 15956 KB Output is correct
14 Correct 84 ms 15956 KB Output is correct
15 Correct 78 ms 15956 KB Output is correct
16 Correct 85 ms 16136 KB Output is correct
17 Correct 80 ms 16036 KB Output is correct
18 Correct 84 ms 16032 KB Output is correct
19 Correct 84 ms 16036 KB Output is correct
20 Correct 82 ms 16032 KB Output is correct
21 Correct 77 ms 16036 KB Output is correct
22 Correct 78 ms 16080 KB Output is correct
23 Correct 77 ms 15956 KB Output is correct
24 Correct 72 ms 15972 KB Output is correct
25 Correct 78 ms 16032 KB Output is correct
26 Correct 74 ms 16036 KB Output is correct
27 Correct 80 ms 16036 KB Output is correct
28 Correct 79 ms 16040 KB Output is correct
29 Correct 79 ms 15956 KB Output is correct
30 Correct 78 ms 15956 KB Output is correct
31 Correct 75 ms 16052 KB Output is correct
32 Correct 79 ms 16040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 16032 KB Output is correct
2 Correct 75 ms 15956 KB Output is correct
3 Correct 75 ms 15956 KB Output is correct
4 Correct 77 ms 16036 KB Output is correct
5 Correct 74 ms 15956 KB Output is correct
6 Correct 78 ms 16036 KB Output is correct
7 Correct 72 ms 16040 KB Output is correct
8 Correct 85 ms 16036 KB Output is correct
9 Correct 76 ms 16040 KB Output is correct
10 Correct 74 ms 16032 KB Output is correct
11 Correct 73 ms 16036 KB Output is correct
12 Correct 74 ms 16036 KB Output is correct
13 Correct 73 ms 16036 KB Output is correct
14 Correct 71 ms 16040 KB Output is correct
15 Incorrect 71 ms 15956 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 79 ms 15956 KB Output is correct
2 Correct 78 ms 16040 KB Output is correct
3 Correct 73 ms 16036 KB Output is correct
4 Correct 74 ms 16036 KB Output is correct
5 Correct 74 ms 15956 KB Output is correct
6 Correct 83 ms 16036 KB Output is correct
7 Correct 78 ms 16048 KB Output is correct
8 Correct 74 ms 16036 KB Output is correct
9 Correct 72 ms 16040 KB Output is correct
10 Correct 81 ms 15956 KB Output is correct
11 Correct 74 ms 16052 KB Output is correct
12 Correct 73 ms 16036 KB Output is correct
13 Correct 74 ms 16016 KB Output is correct
14 Correct 81 ms 16044 KB Output is correct
15 Correct 72 ms 16036 KB Output is correct
16 Correct 74 ms 16036 KB Output is correct
17 Correct 72 ms 16032 KB Output is correct
18 Correct 73 ms 16040 KB Output is correct
19 Correct 76 ms 16052 KB Output is correct
20 Correct 74 ms 16044 KB Output is correct
21 Correct 84 ms 15956 KB Output is correct
22 Correct 74 ms 15956 KB Output is correct
23 Correct 72 ms 16044 KB Output is correct
24 Correct 73 ms 16040 KB Output is correct
25 Correct 75 ms 15956 KB Output is correct
26 Correct 72 ms 16036 KB Output is correct
27 Correct 74 ms 15956 KB Output is correct
28 Correct 74 ms 16036 KB Output is correct
29 Correct 75 ms 15956 KB Output is correct
30 Correct 78 ms 16044 KB Output is correct
31 Correct 77 ms 15956 KB Output is correct
32 Correct 73 ms 15956 KB Output is correct
33 Correct 72 ms 16036 KB Output is correct
34 Correct 75 ms 16036 KB Output is correct
35 Correct 77 ms 15956 KB Output is correct
36 Correct 74 ms 16052 KB Output is correct
37 Correct 74 ms 16048 KB Output is correct
38 Correct 75 ms 16040 KB Output is correct
39 Correct 75 ms 16056 KB Output is correct
40 Correct 77 ms 16044 KB Output is correct
41 Correct 78 ms 16036 KB Output is correct
42 Correct 75 ms 16036 KB Output is correct
43 Correct 74 ms 15956 KB Output is correct
44 Correct 78 ms 16036 KB Output is correct
45 Correct 74 ms 16040 KB Output is correct
46 Correct 77 ms 15928 KB Output is correct
47 Correct 75 ms 16040 KB Output is correct
48 Correct 77 ms 16052 KB Output is correct
49 Correct 74 ms 15984 KB Output is correct
50 Correct 74 ms 16036 KB Output is correct
51 Correct 81 ms 16040 KB Output is correct
52 Correct 107 ms 16084 KB Output is correct
53 Correct 95 ms 16100 KB Output is correct
54 Correct 193 ms 16120 KB Output is correct
55 Correct 171 ms 16116 KB Output is correct
56 Correct 272 ms 16212 KB Output is correct
57 Correct 242 ms 16212 KB Output is correct
58 Correct 352 ms 16200 KB Output is correct
59 Correct 488 ms 16212 KB Output is correct
60 Correct 291 ms 16212 KB Output is correct
61 Correct 74 ms 16044 KB Output is correct
62 Correct 96 ms 16084 KB Output is correct
63 Correct 207 ms 16112 KB Output is correct
64 Correct 120 ms 16116 KB Output is correct
65 Correct 161 ms 16152 KB Output is correct
66 Correct 200 ms 16084 KB Output is correct
67 Correct 240 ms 16204 KB Output is correct
68 Correct 575 ms 16188 KB Output is correct
69 Correct 254 ms 16188 KB Output is correct