Submission #935094

# Submission time Handle Problem Language Result Execution time Memory
935094 2024-02-28T15:26:35 Z HiepVu217 Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 476 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 17;
int n, a, b, y[N];
long long st[4 * N], f[N][N], ans;
void build (int id, int l, int r)
{
    if (l == r)
    {
        st[id] = y[l];
        return;
    }
    int mid = (l + r) / 2;
    build (id * 2, l, mid);
    build (id * 2 + 1, mid + 1, r);
    st[id] = st[id * 2] + st[id * 2 + 1];
}
long long get (int id, int l, int r, int u, int v)
{
    if (u <= l && r <= v)
    {
        return st[id];
    }
    int mid = (l + r) / 2;
    if (v <= mid)
    {
        return get (id * 2, l, mid, u, v);
    }
    if (u > mid)
    {
        return get (id * 2 + 1, mid + 1, r, u, v);
    }
    return get (id * 2, l, mid, u, v) + get (id * 2 + 1, mid + 1, r, u, v);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> a >> b;
    for (int i = 1; i <= n; ++i)
    {
        cin >> y[i];
    }
    build (1, 1, n);
    long long s = 0;
    for (int i = 1; i <= n; ++i)
    {
        fill (f[i] + 1, f[i] + b + 1, 1e18);
        s += y[i];
        f[i][1] = s;
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 2; j <= min (i, b); ++j)
        {
            for (int t = j - 1; t < i; ++t)
            {
                f[i][j] = min (f[i][j], f[t][j - 1] | get (1, 1, n, t + 1, i));
            }
        }
    }
    ans = 1e18;
    for (int i = a; i <= b; ++i)
    {
        ans = min (ans, f[n][i]);
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 476 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -