Submission #1130276

#TimeUsernameProblemLanguageResultExecution timeMemory
1130276ChuanChenBank (IZhO14_bank)C++20
100 / 100
108 ms8652 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 21; 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] = max(dp[msk], {dp[om].first, dp[om].second+b[i]}); } } } if(dp[msk].first == n){ cout << "YES\n"; return 0; } } 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...