# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90088 | Rashidov_Anis | Bank (IZhO14_bank) | C++14 | 190 ms | 652 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[21],b[21],n,m;
void dfs(int x,int sum,int state,int k,int num)
{
int i;
if(x>n)
{
printf("YES");
exit(0);
}
if(sum==0)
{
dfs(x+1,a[x+1],state,0,num);
return;
}
for(i=k;i<m;i++)
{
if(m-num-1<n-x) break;
if(state&(1<<i) || sum<b[i]) continue;
dfs(x,sum-b[i],state|(1<<i),i+1,num+1);
}
}
int main()
{
int i;
scanf("%d %d",&n,&m);
for(i=1;i<=n;i++) scanf("%d",&a[i]);
for(i=0;i<m;i++) scanf("%d",&b[i]);
dfs(1,a[1],0,0,0);
printf("NO");
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |