Submission #1028576

#TimeUsernameProblemLanguageResultExecution timeMemory
1028576vjudge1Bali Sculptures (APIO15_sculpture)C++17
71 / 100
24 ms604 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int const N=105; int const inf=1e13; bool dp[N][N]; int arr[N]; int n,A,B; bool check(int MX){ for (int i = 0; i <=n; ++i) for (int j = 0; j <=n; ++j) dp[i][j]=0; dp[0][0]=1; for(int i=1;i<=n;i++) for(int k=1;k<=i;k++){ int sm=0; for(int j=i;j>=1;j--){ sm+=arr[j]; if(dp[j-1][k-1] && ((MX|sm)==MX)) dp[i][k]=1; } } for(int k=A;k<=B;k++) if(dp[n][k]) return 1; return 0; return 0; } signed main(){ cin>>n>>A>>B; for (int i = 1; i <=n; ++i) cin>>arr[i]; int one=1; int ans=(one<<44)-1; for(int b=43;b>=0;b--) if(check(ans-(one<<b))) ans-=(one<<b); cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...