# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
847585 | Ahmed_Salah7 | Bank (IZhO14_bank) | C++17 | 31 ms | 752 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5, M = 1e6 + 6, mod = 998244353;
vector<int> mask[22];
int a[22], b[22];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
freopen("bank.in","r",stdin);
freopen("bank.out","w",stdout);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
for (int i = 0; i < m; ++i) {
cin >> b[i];
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < (1 << m); ++j) {
int sum = 0;
for (int k = 0; k < m; ++k) {
sum += b[k] * ((j >> k) & 1);
}
if (sum == a[i])
mask[i].push_back(j);
}
}
vector<int> masks;
masks.push_back(0);
for (int i = 0; i < n; ++i) {
vector<int> _masks;
for (auto x: mask[i]) {
for (auto y: masks) {
if (!(x & y)) {
_masks.push_back(x | y);
}
}
}
masks = _masks;
}
cout << (masks.empty() ? "NO":"YES");
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |