Submission #846076

# Submission time Handle Problem Language Result Execution time Memory
846076 2023-09-07T09:13:26 Z tuan13 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
8 ms 63580 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int ar = 2e3 + 5;

int n, a[ar], P, Q;
ll dp[ar][ar], suf[ar][ar], sum[ar];

ll get(int l, int r) {
    return sum[r] - sum[l - 1];
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> P >> Q;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    memset(dp, 0x3f, sizeof(dp));
    memset(suf, 0x3f, sizeof(suf));
    for(int i = 1; i <= n; ++i) {
        dp[i][0] = sum[i];
        for(int j = 1; j < i; ++j) {
            for(int k = 1; k < i; ++k) {
                dp[i][j] = min(dp[i][j], dp[k][j - 1] | get(k + 1, i));
            }
        }
    }
    for(int i = n; i >= 1; --i) {
        suf[i][0] = get(i, n);
        for(int j = 1; j < (n - i + 1); ++j) {
            for(int k = n; k > i; --k) {
                suf[i][j] = min(suf[i][j], suf[k][j - 1] | get(i, k - 1));
            }
        }
    }
    ll ans = 1e18;
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j <= Q - 1; ++j) {
            for(int k = 0; k <= Q; ++k) {
                if(j + k - 1 >= P - 1 && j + k <= Q - 1) ans = min(ans, dp[i][j] | suf[i + 1][k - 1]);
            }
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 63320 KB Output is correct
2 Correct 8 ms 63580 KB Output is correct
3 Incorrect 8 ms 63348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 63324 KB Output is correct
2 Correct 8 ms 63232 KB Output is correct
3 Incorrect 8 ms 63324 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 63324 KB Output is correct
2 Correct 8 ms 63324 KB Output is correct
3 Incorrect 8 ms 63324 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 63320 KB Output is correct
2 Correct 8 ms 63352 KB Output is correct
3 Incorrect 8 ms 63244 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 63324 KB Output is correct
2 Correct 8 ms 63324 KB Output is correct
3 Incorrect 8 ms 63324 KB Output isn't correct
4 Halted 0 ms 0 KB -