Submission #1115626

#TimeUsernameProblemLanguageResultExecution timeMemory
1115626tudor_costinBank (IZhO14_bank)C++11
100 / 100
83 ms11156 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int Nmax=1005; vector<int> v[20*Nmax]; 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))!=0) { 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"<<'\n'; 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...