#include<bits/stdc++.h>
using namespace std;
#define foru(i,a,b) for(int i=(a); i<=(b); ++i)
#define ford(i,a,b) for(int i=(a); i>=(b); --i)
#define rep(i,a) for(int i=0; i<(a); ++i)
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define bit(s,i) (((s)>>(i))&1)
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ll long long
#define _ << " " <<
template <class X, class Y> bool maxi(X &x, Y y){return x<y?x=y,true:false;}
template <class X, class Y> bool mini(X &x, Y y){return x>y?x=y,true:false;}
const int N=2020;
int n,a,b,arr[N];
ll p[N];
namespace sub1{
bool dp[101][101];
void solve(){
ll res=(1LL<<61)-1;
ford(curB,60,0){
res^=(1LL<<curB);
memset(dp,0,sizeof(dp));
dp[0][0]=1;
foru(i,1,n) foru(g,1,i){
foru(j,0,i-1){
if(((p[i]-p[j])&res)==(p[i]-p[j])){
dp[i][g]|=dp[j][g-1];
}
}
}
bool chk=0;
foru(g,a,b) chk|=dp[n][g];
if(!chk) res^=(1LL<<curB);
}
cout<<res<<'\n';
}
}
namespace sub2{
int dp[2020];
void solve(){
ll res=(1LL<<61)-1;
ford(curB,60,0){
res^=(1LL<<curB);
memset(dp,0x3f,sizeof(dp));
dp[0]=0;
foru(i,1,n){
foru(j,0,i-1){
if(((p[i]-p[j])&res)==(p[i]-p[j])){
dp[i]=min(dp[i],dp[j]+1);
}
}
}
if(dp[n]>b) res^=(1LL<<curB);
}
cout<<res<<'\n';
}
}
void solve(){
cin>>n>>a>>b;
foru(i,1,n) cin>>arr[i];
foru(i,1,n) p[i]=p[i-1]+arr[i];
if(a>1) return sub1::solve();
return sub2::solve();
}
int32_t main(){
#define task "test"
if(fopen(task".inp","r")){
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
cin.tie(0)->sync_with_stdio(0);
int tc=1; //cin>>tc;
rep(i,tc){
solve();
}
}
Compilation message (stderr)
sculpture.cpp: In function 'int32_t main()':
sculpture.cpp:88:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
88 | freopen(task".inp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:89:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
89 | freopen(task".out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~| # | 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... |