| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1307494 | msun | Bank (IZhO14_bank) | C++20 | 80 ms | 8576 KiB |
#include <cstdio>
#include <cstring>
using namespace std;
#define MAXNM 20
// #define MAXNM 6
int A[MAXNM], B[MAXNM], dp[1 << MAXNM], partial[1 << MAXNM];
int
main ()
{
// freopen ("test.in", "r", stdin);
int N, M;
scanf ("%d%d", &N, &M);
for (int i = 0; i < N; ++i)
scanf ("%d", &A[i]);
for (int i = 0; i < M; ++i)
scanf ("%d", &B[i]);
const int maxs = 1 << M;
for (int s = 1; s < maxs; ++s) {
for (int x = 0; x < M; ++x) {
if (!(s & (1 << x)))
continue;
int ssubx = s ^ (1 << x);
if (dp[ssubx] < 0)
continue;
int targ = A[dp[ssubx]];
int amt = partial[ssubx] + B[x];
// not enough
if (amt < targ) {
dp[s] = dp[ssubx];
partial[s] += B[x];
} else if (amt == targ) {
dp[s] = dp[ssubx] + 1;
partial[s] = 0;
}
}
if (dp[s] == N) {
puts ("YES");
return 0;
}
}
puts ("NO");
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... | ||||
