제출 #962949

#제출 시각아이디문제언어결과실행 시간메모리
962949raspy은행 (IZhO14_bank)C++14
19 / 100
109 ms1464 KiB
#include <iostream> using namespace std; int a[25]; int b[25]; bool o[25][(1<<20)+1]; void dfs(int n, int m, int ix, int ob) { // cout << ix << " " << ob << " " << a[ix] << "\n"; if (ix == n) { cout << "YES\n"; exit(0); } if (ob == ((1<<m)-1)) return; if (a[ix] < 0) return; if (o[ix][ob]) return; if (a[ix] == 0) dfs(n, m, ix+1, ob); for (int i = 0; i < m; i++) if (((1<<i)&ob) == 0) { a[ix]-=b[i]; dfs(n, m, ix, ob|(1<<i)); a[ix]+=b[i]; } o[ix][ob] = 1; } int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; dfs(n, m, 0, 0); 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...