#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvll = vector<vll>;
#define INF 1e18
const int B = 2005;
bitset<B> dp[B];
void solve() {
int n, l, r; cin >> n >> l >> r;
vll a(n);
for(auto& x : a) cin >> x;
const int K = 40;
ll cand = 0;
for(int i = l; i <= r; i++) dp[n].set(i);
auto f = [&](int b) -> bool {
if(l == 1) {
vll dp(n + 1, INF);
dp[n] = 0;
for(int i = n - 1; i >= 0; i--) {
ll x = 0;
for(int j = i; j < n; j++) {
x += a[j];
if((cand >> b) == (cand | x) >> b) {
dp[i] = min(dp[i], dp[j + 1]);
}
}
}
return dp[0] <= r;
}
for(int i = n - 1; i >= 0; i--) {
dp[i].reset();
ll x = 0;
bitset<B> now;
for(int j = i; j < n; j++) {
x += a[j];
if((cand >> b) == (cand | x) >> b) {
dp[i] |= dp[j + 1] >> 1;
}
}
}
return dp[0][0];
};
for(int b = K - 1; b >= 0; b--) {
if(f(b)) continue;
cand ^= 1LL << b;
}
cout << cand << '\n';
}
signed main() {
int t = 1;
for(int i = 1; i <= t; i++) {
solve();
}
return 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... |