Submission #8114

#TimeUsernameProblemLanguageResultExecution timeMemory
8114dohyun0324Bank (IZhO14_bank)C++98
71 / 100
1077 ms660 KiB
#include<stdio.h> #include<stdlib.h> int a[21],b[21],n,m; void dfs(int x,int sum,int state,int k) { int i; if(x>n) { printf("YES"); exit(0); } if(sum==0) { dfs(x+1,a[x+1],state,0); return; } for(i=k;i<m;i++) { if(state&(1<<i) || sum<b[i]) continue; dfs(x,sum-b[i],state+(1<<i),i+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); printf("NO"); return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~
bank.cpp:27:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++) scanf("%d",&a[i]);
                       ~~~~~^~~~~~~~~~~~
bank.cpp:28:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=0;i<m;i++) scanf("%d",&b[i]);
                      ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...