Submission #1130275

#TimeUsernameProblemLanguageResultExecution timeMemory
1130275ChuanChenBank (IZhO14_bank)C++20
19 / 100
67 ms8520 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 21, lim = 1e3+4; int n, m, a[MAXN], b[MAXN]; pair<int, int> dp[1<<MAXN]; bool ans; int main(){ cin.tie(0)->sync_with_stdio(0); cin >> n >> m; for(int i = 1; i <= n; i++){ cin >> a[i]; } for(int i = 0; i < m; i++){ cin >> b[i]; } for(int msk = 1; msk < (1<<m); msk++){ for(int i = 0; i < m; i++){ if(msk&(1<<i)){ int om = msk-(1<<i); if(a[dp[om].first+1] == dp[om].second+b[i]){ dp[msk] = make_pair(dp[om].first+1, 0); break; } else{ dp[msk] = make_pair(dp[om].first, dp[om].second+b[i]); } } } if(dp[msk] == make_pair(n, 0)) ans = true; } if(ans) cout << "YES\n"; else cout << "NO\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...