Submission #739920

#TimeUsernameProblemLanguageResultExecution timeMemory
739920Desh03Bank (IZhO14_bank)C++17
46 / 100
1 ms448 KiB
#include <bits/stdc++.h> using namespace std; const int mxn = 1001; int m, cnt = 0; vector<int> b; vector<vector<int>> dp(mxn, vector<int>(21, 0)); vector<int> mp(mxn); void recurse(int sum, int i) { if (dp[sum][i]) return; mp[sum] = 1; dp[sum][i] = 1; if (i == m) return; if (sum + b[i] < mxn) recurse(sum + b[i], i + 1); recurse(sum, i + 1); } void solve() { int n; cin >> n >> m; vector<int> a(n); b.resize(m); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; recurse(0, 0); for (int i = 0; i < n; i++) { if (!mp[a[i]]) { cout << "NO"; return; } } cout << "YES"; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int t = 1; // cin >> t; for (int i = 1; i <= t; i++) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...