# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68582 | cdemirer | Bank (IZhO14_bank) | C++17 | 76 ms | 7704 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>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef pair<double, double> dodo;
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
int N, M;
int A[20], B[20];
vi masklist[20001];
bool mark[1048576];
void dfs(int pos, int mask) {
}
int main(int argc, char **argv) {
ios_base::sync_with_stdio(0);
cin.tie(0);
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 j = 1; j < (1<<M); j++) {
int sum = 0;
for (int k = 0; k < M; k++) if (j & (1<<k)) sum += B[k];
masklist[sum].pb(j);
}
int sum = 0;
vi masks;
for (int i = 0; i < N; i++) {
sum += A[i];
masks.clear();
for (int j = 0; j < masklist[sum].size(); j++) {
int m = masklist[sum][j];
if (i == 0 || mark[m]) masks.pb(m);
}
if (masks.empty()) {
cout << "NO" << endl;
return 0;
}
memset(mark, 0, sizeof(mark));
for (int i = 0; i < masks.size(); i++) {
int m = masks[i];
mark[m] = true;
for (int k = 0; k < M; k++) {
mark[m | (1<<k)] = true;
}
}
}
cout << "YES" << endl;
return 0;
}
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... |