Submission #136600

#TimeUsernameProblemLanguageResultExecution timeMemory
136600FedericoSBank (IZhO14_bank)C++14
25 / 100
1073 ms504 KiB
#include <iostream> using namespace std; int N,M; int A[25],B[25]; bool DP[2000000]; bool F(int b){ int S=0; for(int j=0;j<M;j++) if(b&(1<<j)) S+=B[j]; int i=0; for(;i<N;i++){ if(S>=A[i]) S-=A[i]; else break; } if(i==N) return true; int P=A[i]-S; bool res=false; for(int j=0;j<M;j++) if(!(b&(1<<j)) and B[j]<=P) res|=F(b|(1<<j)); return res; } int main(){ cin>>N>>M; for(int i=0;i<N;i++) cin>>A[i]; for(int i=0;i<M;i++) cin>>B[i]; cout<<(F(0)?"YES":"NO"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...