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 <stdio.h>
int N,A,B,G[2020];
long long X[2020];
bool gr[101][101];
int main(){
scanf("%d %d %d", &N,&A,&B);
for(int i=1;i<=N;i++){
scanf("%lld", &X[i]);
X[i]+=X[i-1];
}
long long ans=0;
for(int k=40;k>=0;k--){
long long want=ans+(1ll<<k)-1;
gr[0][0]=1;
for(int i=1;i<=N;i++) for(int j=0;j<=B;j++) gr[j][i]=0;
for(int j=1;j<=N;j++) for(int i=1;i<=j;i++){
long long see=X[j]-X[i-1];
if((see|want)==want){
for(int l=0;l<B;l++) if(gr[l][i-1]) gr[l+1][j]=1;
}
}
bool good=0;
for(int i=A;i<=B;i++) if(gr[i][N]) good=1;
if(!good) ans+=(1ll<<k);
}
printf("%lld\n", ans);
}
# | 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... |