#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 1e9
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;
auto f = [&](int b) -> bool {
vi dp_min(n + 1, inf), dp_max(n + 1, -inf);
dp_min[n] = dp_max[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) == (x | cand) >> b) {
dp_min[i] = min(dp_min[i], dp_min[j + 1] + 1);
dp_max[i] = max(dp_max[i], dp_max[j + 1] + 1);
}
}
}
return dp_min[0] <= r && dp_max[0] >= l;
};
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... |