Submission #33770

#TimeUsernameProblemLanguageResultExecution timeMemory
33770dqhungdlBali Sculptures (APIO15_sculpture)C++14
71 / 100
759 ms10076 KiB
#include <bits/stdc++.h> using namespace std; const int64_t MAX=40; int64_t n,A,B,a[2005]; bool Free[2005][2005],F[2005][2005]; bool f(int64_t i,int64_t j,int64_t mask) { if(Free[i][j]==true) return F[i][j]; Free[i][j]=true; if(j>B) return F[i][j]=false; if(i>n) return F[i][j]=(A<=j); for(int64_t t=i;t<=n;t++) { int64_t tmp=a[t]-a[i-1]; if((mask|tmp)==mask&&f(t+1,j+1,mask)==true) return F[i][j]=true; } return F[i][j]=false; } int main() { ios_base::sync_with_stdio(false); //freopen("TEST.INP","r",stdin); cin>>n>>A>>B; for(int64_t i=1;i<=n;i++) { cin>>a[i]; a[i]+=a[i-1]; } int64_t res=(int64_t(1)<<MAX)-1; for(int64_t i=MAX-1;i>=0;i--) { for(int64_t j=1;j<=n;j++) for(int64_t t=0;t<=B;t++) Free[j][t]=false; if(f(1,0,res-(int64_t(1)<<i))==true) res-=int64_t(1)<<i; } cout<<res; }
#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...