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<cstdio>
int a[2222];
int d[2222];
int dd[222][222];
int main()
{
long long r=0,t;
int i,j,k,n,m,l,tt;
scanf("%d%d%d",&n,&m,&l);
for(i=1;i<=n;i++)scanf("%d",&a[i]);
if(m==1)
{
for(i=45;i>=0;i--)
{
for(j=1;j<=n;j++)d[j]=1e9;
for(j=0;j<n;j++)
{
t=0;
for(k=j+1;k<=n;k++)
{
t+=a[k];
if((t>>(i+1))&~(r>>(i+1)))continue;
if((t>>i)&1)continue;
if(d[k]>d[j]+1)d[k]=d[j]+1;
}
}
if(d[n]>l)r|=1LL<<i;
}
printf("%lld\n",r);
return 0;
}
for(i=45;i>=0;i--)
{
dd[0][0]=1;
for(j=1;j<=n;j++)for(k=0;k<=n;k++)dd[j][k]=0;
for(j=0;j<n;j++)
{
t=0;
for(k=j+1;k<=n;k++)
{
t+=a[k];
if((t>>(i+1))&~(r>>(i+1)))continue;
if((t>>i)&1)continue;
for(tt=0;tt<n;tt++)if(dd[j][tt])dd[k][tt+1]=1;
}
}
for(j=m;j<=l;j++)if(dd[n][j])break;
if(j>l)r|=1LL<<i;
}
printf("%lld\n",r);
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... |