Submission #722001

#TimeUsernameProblemLanguageResultExecution timeMemory
722001ovidiush11Bank (IZhO14_bank)C++14
100 / 100
143 ms4556 KiB
#include <bits/stdc++.h> using namespace std; const int N = 20; int pre[N],dp[1<<N],b[N+2]; int main() { int n,m; cin>>n>>m; for(int i = 1;i <= n;i++) { cin>>pre[i]; pre[i] += pre[i-1]; } for(int i = 0;i < m;i++)cin>>b[i]; for(int i = 0;i < (1<<m);i++) { int s = 0; for(int j = 0;j < m;j++)if(i&(1<<j))s += b[j]; for(int j = 0;j < m;j++) { if(i&(1<<j)) { if(pre[dp[i^(1<<j)] + 1] == s)dp[i] = max(dp[i],dp[i^(1<<j)]+1); else dp[i] = max(dp[i],dp[i^(1<<j)]); } } } if(dp[(1<<m) - 1] < n)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...