Submission #1116165

#TimeUsernameProblemLanguageResultExecution timeMemory
1116165ezzzayBank (IZhO14_bank)C++14
100 / 100
78 ms8820 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int dp[(1<<21)]; int a[25],b[25]; signed main(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++){ cin>>a[i]; a[i]+=a[i-1]; } for(int j=0;j<m;j++) cin>>b[j]; dp[0]=-1; for(int mask=0;mask<(1<<m);mask++){ int sum=0; dp[mask]=-1; for(int i=0;i<m;i++){ if((mask&(1<<i))){ dp[mask]=max(dp[mask],dp[mask ^ (1<<i)]); sum+=b[i]; } } if(sum==a[dp[mask]+1]) dp[mask]++; } if(dp[(1<<m)-1]==n) cout<<"YES"; else cout<<"NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...