답안 #538309

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
538309 2022-03-16T15:11:51 Z Servus2022 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 340 KB
#include <iostream>

using namespace std;

const int NMAX = 2e3 + 2;
const long long INF = 1LL * 1e16;

int N, A, B;
int v[NMAX];
long long dp[NMAX][NMAX];
long long sp[NMAX];

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

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

    return;
}

static inline long long mymin (long long a, long long b)
{
    return (a < b ? a : b);
}

static inline long long Query (int left, int right)
{
    return (sp[right] - sp[left - 1]);
}

static inline void Solve()
{
    for(int i = 0; i <= N; ++i)
        for(int j = 0; j <= N; ++j)
            dp[i][j] = INF;

    for(int i = 1; i <= N; ++i)
        dp[i][1] = Query(1, i);

    for(int i = 1; i <= N; ++i)
        for(int j = 2; j <= i; ++j)
            for(int k = 2; k <= i; ++k)
                dp[i][j] = mymin(dp[k - 1][j - 1] | Query(k, i), dp[i][j]);

    long long ans = INF;
    for(int i = A; i <= B; ++i)
        ans = mymin(dp[N][i], ans);
    cout << ans << '\n';

    return;
}

int main()
{
    Read();

    Solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -