This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define N 2010
#define ll long long
#define fs first
#define sc second
#define ii pair<ll,int>
#define pb push_back
#define int ll
int S,n,A,B,a[N],ans,dp[N][N];
void solve(int id)
{
S+=(1ll<<id);
memset(dp,0,sizeof(dp));
for(int i=1;i<=n;i++)
{
if((a[i]&S)==0)
dp[i][1]=1;
dp[i][1]+=dp[i-1][1];
}
for(int j=2;j<=B;j++)
{
for(int i=j;i<=n;i++)
{
for(int t=j-1;t<i;t++)
if((S&(a[i]-a[t]))==0&&dp[t][j-1]>dp[t-1][j-1])
{
dp[i][j]=1;
break;
}
dp[i][j]+=dp[i-1][j];
}
}
for(int i=A;i<=B;i++)
if(dp[n][i]>dp[n-1][i])
return;
ans+=(1ll<<id);
S-=(1ll<<id);
}
int32_t main()
{
#ifdef SKY
freopen("A.inp","r",stdin);
freopen("A.out","w",stdout);
#endif // SKY
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>A>>B;
for(int i=1;i<=n;i++)
cin>>a[i],a[i]+=a[i-1];
for(int i=40;i>=0;i--)
solve(i);
cout<<ans;
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... |