# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
21958 | mohammad_kilani | Bali Sculptures (APIO15_sculpture) | C++14 | 236 ms | 3224 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;
const int N = 111;
int n , a , b , arr[N];
bool dp[N][N][50];
bool vis[N][N][50];
bool canbit[55];
void printbinary(long long num){
for(int i=32;i>=0;i--){
cout << ((num>>i)&1);
}
cout << endl;
}
bool check(long long num,int curbit){
for(int i=46;i>=curbit;i--){
if(canbit[i] == 1)
continue;
if(((num >> i)&1) == 1)
return false;
}
return true;
}
bool solve(int i,int j,int bit){
if(j > b)
return false;
if(i == n){
if(j >= a)
return true;
return false;
}
if(vis[i][j][bit] == true)
return dp[i][j][bit];
vis[i][j][bit] = true;
long long sum = 0 ;
bool can = false;
for(int k = i;k<n;k++){
sum += (long long)arr[k];
if(check(sum,bit) == 0)
continue;
if(solve(k+1,j+1,bit) == true){
can = true;
}
}
return dp[i][j][bit] = can;
}
int main(){
//freopen("in.txt","r",stdin);
memset(dp,-1,sizeof(dp));
scanf("%d%d%d",&n,&a,&b);
for(int i=0;i<n;i++){
scanf("%d",&arr[i]);
}
long long ans = 0 ;
for(int i=46;i>=0;i--){
if(!solve(0,0,i)){
ans += ((long long)1 << (long long)i);
canbit[i] = 1;
}
}
cout << ans << endl;
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... |