# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963592 | maxFedorchuk | Bank (IZhO14_bank) | C++17 | 0 ms | 0 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;
int a[22],b[22],n,m;
void cnt(int msk,int in,int zalsum,int munin,int k0)
{
if(in>n)
{
cout<<"YES\n";
exit(0);
}
if(zalsum==0)
{
cnt(msk,in+1,a[in+1],0,k0);
return;
}
if(k0<(n-in+1))
{
return;
}
for(int i=munin+1;i<=m;i++)
{
if(!((msk>>i)&1))
{
if(zalsum>=b[i])
{
cnt(msk|(1<<i),in,zalsum-b[i],i,k0-1);
}
else
{
break;
}
}
}
}
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
for(int i=1;i<=m;i++)
{
cin>>b[i];
}
dfs(1,a[1],0,0,0);
cout<<"NO\n";
return 0;
}