Submission #735576

#TimeUsernameProblemLanguageResultExecution timeMemory
735576bin9638Bali Sculptures (APIO15_sculpture)C++17
71 / 100
1054 ms32136 KiB
#include <bits/stdc++.h> using namespace std; #define N 2010 #define ll long long #define fs first #define sc second #define ii pair<ll,int> #define pb push_back #define int ll int S,n,A,B,a[N],ans,dp[N][N]; void solve(int id) { S+=(1ll<<id); memset(dp,0,sizeof(dp)); for(int i=1;i<=n;i++) { if((a[i]&S)==0) dp[i][1]=1; dp[i][1]+=dp[i-1][1]; } for(int j=2;j<=B;j++) { for(int i=j;i<=n;i++) { for(int t=j-1;t<i;t++) if((S&(a[i]-a[t]))==0&&dp[t][j-1]>dp[t-1][j-1]) { dp[i][j]=1; break; } dp[i][j]+=dp[i-1][j]; } } for(int i=A;i<=B;i++) if(dp[n][i]>dp[n-1][i]) return; ans+=(1ll<<id); S-=(1ll<<id); } int32_t main() { #ifdef SKY freopen("A.inp","r",stdin); freopen("A.out","w",stdout); #endif // SKY ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n>>A>>B; for(int i=1;i<=n;i++) cin>>a[i],a[i]+=a[i-1]; for(int i=40;i>=0;i--) solve(i); cout<<ans; 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...