Submission #472642

#TimeUsernameProblemLanguageResultExecution timeMemory
472642dqkBank (IZhO14_bank)C++17
46 / 100
91 ms4444 KiB
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int n, m; std::cin >> n >> m; std::vector<int> a(n), b(m); for (int i = 0; i < n; ++i) { std::cin >> a[i]; } for (int i = 0; i < m; ++i) { std::cin >> b[i]; } std::map<int, std::vector<int>> s; for (int x : a) { s[x] = {}; } std::vector<int> dp(1 << m, 0); for (int i = 0; i < (1 << m); ++i) { for (int j = 0; j < m; ++j) { if (i & (1 << j)) { dp[i] = dp[i ^ (1 << j)] + b[j]; } } if (s.count(dp[i])) { s[dp[i]].push_back(i); } } std::vector<int> u, v; u = {0}; for (auto &[_, y] : s) { for (int x : u) { for (int z : y) { if (x & z) continue; v.push_back(x | z); } } u = v; v = {}; } if (u.size()) { std::cout << "YES\n"; } else { std::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...