Submission #649522

#TimeUsernameProblemLanguageResultExecution timeMemory
649522rsjwBank (IZhO14_bank)C++17
19 / 100
9 ms8404 KiB
#include <bits/stdc++.h> using namespace std; int a[20],b[20],f[1<<20],g[1<<20]; int main() { int n,m,i,j; cin>>n>>m; for(i=0;i<n;i++) cin>>a[i]; for(i=0;i<m;i++) cin>>b[i]; for(i=0;i<(1<<m);i++) { for(j=0;j<m;j++) { if(i&(1<<j)) { g[i]=g[i^(1<<j)]+b[j]; if(g[i]==a[f[i^(1<<j)]]) f[i]=f[i^(1<<j)]+1,g[i]=0; else f[i]=f[i^(1<<j)]; if(f[i]==n) return printf("YES\n"),0; break; } } } printf("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...