# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106938 | nxteru | Bali Sculptures (APIO15_sculpture) | C++14 | 84 ms | 512 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>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 1000000000000000000
int n,a,b;
ll y[2005],ans=(1LL<<41LL)-1;
bool check(void){
if(a==1){
int dp[2005];
for(int i=0;i<=n;i++)dp[i]=n+1;
dp[0]=0;
for(int i=0;i<n;i++){
ll s=0;
for(int j=i+1;j<=n;j++){
s+=y[j];
if((ans|s)==ans)dp[j]=min(dp[j],dp[i]+1);
}
}
return dp[n]<=b;
}else{
bool dp[105][105];
for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)dp[i][j]=false;
dp[0][0]=true;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(!dp[i][j])continue;
ll s=0;
for(int k=i+1;k<=n;k++){
s+=y[k];
if((ans|s)==ans)dp[k][j+1]=true;
}
}
}
bool res=false;
for(int i=a;i<=b;i++)res|=dp[n][i];
return res;
}
}
int main(void){
scanf("%d%d%d",&n,&a,&b);
for(int i=1;i<=n;i++)scanf("%lld",y+i);
for(ll i=40;i>=0;i--){
ans^=(1LL<<i);
if(!check())ans^=(1LL<<i);
}
printf("%lld\n",ans);
}
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... |