Submission #211644

# Submission time Handle Problem Language Result Execution time Memory
211644 2020-03-20T22:13:54 Z DS007 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
5 ms 512 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N = 6;
int n, a, b;
int y[N], p[N];

void solveTestCase() {
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) cin >> y[i];

    p[0] = y[0];
    for (int i = 1; i < n; i++)
        p[i] = y[i] + p[i - 1];

    int ans = 0;
    for (int i = 40; i >= 0; i--) {
        int dp[n];
        fill(dp, dp + n, 1e14);
        int up = ans + (1ll << i);
        bool check = y[0] < up;
        dp[0] = 1;

        for (int j = 1; j < n; j++) {
            check = check && y[j] < up;
            if (p[j] < up && (p[j] | up) < up + (1ll << i) && (p[j] & (1ll << i)) == 0)
                dp[j] = 1;

            for (int k = j - 1; k >= 0; k--) {
                if ((p[j] - p[k + 1] + y[k + 1]) < up && ((p[j] - p[k + 1] + y[k + 1]) | up) < up + (1ll << i) && ((p[j] - p[k + 1] + y[k + 1]) & (1ll << i)) == 0)
                    dp[j] = min(dp[j], dp[k] + 1);
            }
        }

        if (!check || dp[n - 1] > b)
            ans = up;
    }

    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int test = 1;
    //cin >> test;
    while (test--)
        solveTestCase();
}
# 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 4 ms 384 KB Output is correct
4 Incorrect 5 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Incorrect 4 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 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 Incorrect 5 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 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 Incorrect 4 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 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 Incorrect 4 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -