Submission #844909

#TimeUsernameProblemLanguageResultExecution timeMemory
844909Desh03Bank (IZhO14_bank)C++17
0 / 100
2 ms348 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1000; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } bitset<N + 1> dp; dp[0] = 1; for (int i = 0; i < m; i++) { int x; cin >> x; for (int i = 0; i < 1000; i++) { dp |= dp << x; } } vector<bool> f(1 << n); f[0] = 1; for (int i = 1; i < (1 << n); i++) { for (int j = 0; j < n; j++) { if (i >> j & 1) { if (dp[a[j]] && f[i ^ (1 << j)]) { f[i] = 1; } } } } cout << (f[(1 << n) - 1] ? "YES\n" : "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...