Submission #883670

#TimeUsernameProblemLanguageResultExecution timeMemory
883670kokoueBank (IZhO14_bank)C++14
0 / 100
1097 ms348 KiB
#include<bits/stdc++.h> using namespace std; int n,m; int a[30],b[30]; bool try_sum(int sum,int idx) { // sum-=b[idx]; if(sum==0) return true; if(sum<0) return false; for(int i=idx+1;i<m;i++) { if(try_sum(sum-b[idx],i)) return true; if(try_sum(sum,i)) return true; } return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>m; for(int i=0;i<n;i++) { cin>>a[i]; } for(int i=0;i<m;i++) { cin>>b[i]; } sort(b,b+n); for(int i=0;i<n;i++) { if(try_sum(a[i],0)) cout<<"YES\n"; else cout<<"NO\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...