# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42092 | minchurl | Bali Sculptures (APIO15_sculpture) | C++11 | 2 ms | 532 KiB |
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>
#define MAX_N 2005
#define inf (1LL<<60)
#define LL long long
using namespace std;
LL n,a,b,ans,arr[MAX_N];
LL t[MAX_N],ct[MAX_N][MAX_N];
LL case1(){
LL i,j,k,sum;
for(i=0;i<=n;i++) for(j=0;j<=n;j++) ct[i][j]=inf;
ans=inf;
ct[0][0]=0;
for(i=1;i<=n;i++){
for(j=1;j<=i;j++){
sum=0;
for(k=i;k>=1;k--){
sum+=arr[k];
ct[j][i]=min(ct[j][i],ct[j-1][k-1]|sum);
if(i==n && j>=a && j<=b) ans=min(ans,ct[j][i]);
}
}
}
return ans;
}
bool is_ok(LL x){
LL i,j,sum,test,y,z,k;
y=inf-1;y-=(1LL<<x)-1;
z=ans&y;
for(i=1;i<=n;i++) t[i]=inf;
t[0]=0;
for(i=1;i<=n;i++){
sum=0;
for(j=i;j>=1;j--){
sum+=arr[j];
k=sum&y;
if((z|k)==z) t[i]=min(t[i],t[j-1]+1);
}
}
return t[n]<=b;
}
int main(){
LL i,x;
scanf("%lld",&n);
scanf("%lld %lld",&a,&b);
for(i=1;i<=n;i++) scanf("%lld",&arr[i]);
if(n<=100) return !printf("%lld\n",case1());
ans=0;
for(i=50;i>=0;i--) ans|=is_ok(i)?0LL:(1LL<<i);
printf("%lld\n",ans);
return 0;
}
Compilation message (stderr)
# | 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... |