#include <bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
#define pb push_back
#define pll array<ll, 2>
#define vec vector
#define all(x) x.begin(), x.end()
#define allr(X) X.rbegin(), X.rend()
using namespace std;
const ll sz = 3e5 + 5;
const ll N = 1e6 + 5;
const ll inf = 1e17;
const ll mod = 924844033;
const ll bl = 400;
void _(){
ll n, a, b; cin >> n >> a >> b;
vector<ll>v(n); for(ll &i : v) cin >> i;
vector<vector<ll>>dp(n + 1, vector<ll>(b + 1, inf));
dp[1][1] = v[0]; vector<ll>pref(n + 1, 0);
for(ll i = 0; i < n; i++) pref[i + 1] = pref[i] + v[i];
dp[0][0] = 0;
for(ll i = 1; i <= n; i++){
for(ll j = 1; j <= min(n, b); j++){
for(ll k = j - 1; k < i; k++){
ll nw = dp[k][j - 1] | (pref[i] - pref[k]);
dp[i][j] = min(dp[i][j], nw);
}
}
}
ll ans = inf;
for(ll i = a; i <= b; i++) ans = min(ans, dp[n][i]);
cout << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0); _();
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |