제출 #883672

#제출 시각아이디문제언어결과실행 시간메모리
883672kokoue은행 (IZhO14_bank)C++14
0 / 100
1058 ms452 KiB
#include<bits/stdc++.h> using namespace std; int n,m; int a[30],b[30]; bool try_sum(int sum,int 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...