# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1151037 | hungandhimself | Bank (IZhO14_bank) | C++20 | 0 ms | 0 KiB |
cin >> a[i];
mark[a[i]] = true;
}
for (int i = 1; i <= m; i++) {
cin >> b[i];
}
for (int s = 0; s < (1 << n); s++) {
int sum = 0;
for (int mask = 0; mask < n; mask++) {
if (s & (1 << mask)) {
sum += b[mask + 1];
}
}
if (mark[sum])
subset[sum].push_back(s);
}
memset(dp, false, sizeof dp);
dp[1][0] = true;
for (int i = 1; i < n; i++) {
for (int s = 0; s < (1 << n); s++) {
if (dp[i][s] == false) continue;
for (int x : subset[a[i]]) {
if ((s | x) == x) {
dp[i + 1][s ^ x] = true;
}
}
}
}
cout << (*max_element(dp[n], dp[n] + 1) == true ? "YES" : "NO") << '\n';
}
/**
B1 : kiểm tra lại code templete, code đã học thuộc
đọc kĩ đề
nháp chưa
kiểm tra lại code, đặc biệt là những chỗ đã học thuộc (nhiều khi sai ở đó)
**/
signed main () {
ios_base::sync_with_stdio (false);
cin.tie (0); cout.tie (0);
#ifndef ONLINE_JUDGE
// freopen ("movie.in", "r", stdin);
// freopen ("movie.out", "w", stdout);
#else // online submission
#endif
/// i have a contest soon and i need to learn a much as possible
/// so let become familiar with a bunch of different problems and solution ideas
// stop learning useless algorithm (with you) and solve more problems
//Cứ 7 lần nộp thì chỉ được 1 lần sai
int test = 1;
// cin >> test;
while (test--) runcase(test);
// return 0;
}