Submission #785007

# Submission time Handle Problem Language Result Execution time Memory
785007 2023-07-16T22:27:40 Z aykhn Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 328 KB
#include <bits/stdc++.h>

// author: aykhn

using namespace std;

typedef long long ll;

#define TC int t; cin >> t; while (t--) _();
#define OPT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pii pair<int, int>
#define mpr make_pair
#define eb emplace_back
#define new int32_t
#define pb push_back
#define ts to_string
#define fi first
#define se second
#define int ll
#define ins insert
#define inf 0x3F3F3F3F
#define infll 0x3F3F3F3F3F3F3F3FLL
#define bpc __builtin_popcount

int n, a, b;
int arr[2001];
int dp[2001];

int f(int i, int d)
{
    if (i == n + 1)
    {
        if (d < a) return infll;
        return 0;
    }
    if (d > b) return infll;
    if (dp[i] != -1) return dp[i];

    int sum = 0;
    int res = infll;
    for (int j = i; j <= n; j++)
    {
        sum += arr[j];
        res = min(res, sum | f(j + 1, d + 1));
    }

    return dp[i] = res;
}
new main()
{
    OPT;
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++)
    {
        dp[i] = -1;
        cin >> arr[i];
    }

    cout << f(1, 1);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 328 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -