Submission #1123967

#TimeUsernameProblemLanguageResultExecution timeMemory
1123967kamBank (IZhO14_bank)C++20
71 / 100
1095 ms6980 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; bool f = 0; vector<int>a; vector<vector<int>>gp(1e3 + 5); void dfs(int mask, int u) { if (u == -1) { f = 1; return; } for (int& v : gp[a[u]]) { if ((v & mask) != v) continue; dfs(mask ^ v, u - 1); } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<int> b(m); a = vector<int>(n); for (int& i : a) cin >> i; for (int& i : b) cin >> i; for (int i = 1; i < (1 << m); i++) { int sum = 0; for (int j = 0; j < m; j++) { if (i & (1 << j)) { sum += b[j]; } } if(sum > 1e3) continue; gp[sum].push_back(i); } dfs((1 << m) - 1, n - 1); if (f) 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...