Submission #358538

#TimeUsernameProblemLanguageResultExecution timeMemory
358538nicolaalexandraBank (IZhO14_bank)C++14
71 / 100
1091 ms504 KiB
#include <bits/stdc++.h> using namespace std; int v[22],a[22]; vector <int> L[22]; int n,m,i,sol; void back (int pas, int mask){ if (sol) return; if (pas > n){ sol = 1; return; } for (auto it : L[pas]){ if ( (it & mask) == 0) back (pas+1,mask | it); } } int main (){ //ifstream cin ("date.in"); //ofstream cout ("date.out"); cin>>n>>m; for (i=1;i<=n;i++) cin>>v[i]; for (i=0;i<m;i++) cin>>a[i]; for (i=1;i<=n;i++){ for (int mask=0;mask<(1<<m);mask++){ int sum = 0; for (int bit=0;bit<m;bit++){ if (mask & (1<<bit)) sum += a[bit]; } if (sum == v[i]) L[i].push_back(mask); } } back (1,0); if (sol) cout<<"YES"; 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...