Submission #1305505

#TimeUsernameProblemLanguageResultExecution timeMemory
1305505Ekber_EkberBali Sculptures (APIO15_sculpture)C++20
0 / 100
1 ms580 KiB
#include <bits/stdc++.h>
#define GOOD_LUCK ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;

constexpr int MAX = 2e+5 + 1, INF = 2e+16, MOD = 1e+9 + 7, K = 31;

void _() {
    int n, a, b;
    cin >> n >> a >> b;
    vector <int> v(n), pr;
    for (int &i : v) cin >> i;
    pr = v;
    for (int i = 1; i < n; i++) pr[i] += pr[i-1];
    vector <vector <int>> dp(n+1, vector <int>(b+1, INF));
    for (int i= 1; i <= n; i++) dp[i][1] = pr[i-1];
    for (int i = 1; i <= n; i++) {
        for (int j = 2; j <= b; j++) {
            for (int k = 0; k < i; k++) {
                dp[i][j] = min(dp[i][j], (dp[k][j-1] | (pr[i-1] - (k == 0 ? 0 : pr[k-1]))));
            }
        }
    }
    int res = INF;
    for (int i = a; i <= b; i++) res = min(res, dp[n][i]);
    cout << res;
}

signed main() {

    GOOD_LUCK

    int tests=1;
    // cin >> tests;
    for (int i=1; i <= tests; i++) {
        _();
        cout << endl;
    }

    return 0;
}
/*
6 1 3
8 1 2 1 5 4
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...