| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1307496 | msun | 은행 (IZhO14_bank) | C++20 | 98 ms | 8612 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]);
memset (dp, -1, sizeof dp);
memset (partial, -1, sizeof partial);
dp[0] = 0;
partial[0] = 0;
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] = amt;
} else if (amt == targ) {
dp[s] = dp[ssubx] + 1;
partial[s] = 0;
}
}
if (dp[s] == N) {
puts ("YES");
return 0;
}
}
puts ("NO");
return 0;
}
컴파일 시 표준 에러 (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... | ||||
