#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF = 1e18;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int tc = 1;
// cin >> tc;
for (;tc--;) {
ll N, A, B; cin >> N >> A >> B;
vector <ll> Y(N + 5);
for (int i = 1; i <= N; i++) {
cin >> Y[i];
}
ll ans = 0, del = 0;
for (int bit = 60; bit >= 0; --bit) {
// try to not include bit i
vector <ll> dp(N + 5, INF);
dp[0] = 0;
del += (1LL << bit);
for (int i = 1; i <= N; i++) {
ll sm = 0;
for (int j = i; j >= 1; --j) {
sm += Y[j];
if (!(sm & del)) {
// cout << i << " " << j << " " << bit << "\n";
dp[i] = min(dp[i], dp[j - 1] + 1);
}
}
}
if (dp[N] > B) {
ans += (1LL << bit);
del -= (1LL << bit);
}
// cout << del << "\n";
}
cout << ans << "\n";
}
}
/*
Bali Sculptures
*/
| # | 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... |