Submission #386543

#TimeUsernameProblemLanguageResultExecution timeMemory
386543ScarletSBank (IZhO14_bank)C++17
71 / 100
1089 ms1380 KiB
#include <bits/stdc++.h> using namespace std; vector<int> v[21]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,m,s,l; cin>>n>>m; int p[n+1],a[m]; p[0]=0; v[0].push_back(0); for (int i=1;i<=n;++i) cin>>p[i],p[i]+=p[i-1]; for (int i=0;i<m;++i) cin>>a[i]; for (int i=1;i<(1<<m);++i) { s=0; for (int j=0;j<m;++j) if (i&(1<<j)) s+=a[j]; l=0; for (int j=1;j<=n;++j) if (s==p[j]) l=j; if (s!=p[l]) continue; for (int j : v[l-1]) if ((i&j)==j) { v[l].push_back(i); break; } } if (v[n].empty()) cout<<"NO"; else cout<<"YES"; 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...