# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145986 | mhy908 | Bali Sculptures (APIO15_sculpture) | C++14 | 180 ms | 524 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 F first
#define S second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n, a, b;
LL arr[2010], sum[2010];
int dp[2010];
bool ch[110][110];
bool poss(LL num)
{
if(a==1){
for(int i=1; i<=n; i++){
dp[i]=b+1;
for(int j=1; j<=i; j++){
LL t=sum[i]-sum[j-1];
if((t&(~num))==0){
dp[i]=min(dp[i], dp[j-1]+1);
}
}
}
return dp[n]<=b;
}
else{
memset(ch, 0, sizeof(ch));
ch[0][0]=true;
for(int i=1; i<=n; i++){
for(int j=1; j<=i; j++){
for(int k=1; k<=i; k++){
LL t=sum[i]-sum[k-1];
if(ch[k-1][j-1]&&((t&(~num))==0)){
ch[i][j]=true;
}
}
}
}
for(int i=a; i<=b; i++){
if(ch[n][i])return true;
}
return false;
}
}
int main()
{
scanf("%d %d %d", &n, &a, &b);
for(int i=1; i<=n; i++){
scanf("%lld", &arr[i]);
sum[i]=sum[i-1]+arr[i];
}
LL ans=(1LL<<55)-1LL;
for(int i=54; i>=0; i--){
LL temp=(1LL<<i);
if(poss(ans&(~temp)))ans&=(~temp);
}
printf("%lld", 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... |