結果

問題 No.50 おもちゃ箱
ユーザー ckawatakckawatak
提出日時 2019-01-14 19:46:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 623 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 76,824 KB
最終ジャッジ日時 2023-09-04 20:43:19
合計ジャッジ時間 7,017 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 71 ms
71,068 KB
testcase_04 AC 71 ms
71,488 KB
testcase_05 AC 201 ms
76,488 KB
testcase_06 AC 85 ms
76,528 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 84 ms
76,708 KB
testcase_18 AC 86 ms
76,656 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 84 ms
76,572 KB
testcase_22 AC 85 ms
76,824 KB
testcase_23 AC 79 ms
76,716 KB
testcase_24 AC 72 ms
71,448 KB
testcase_25 AC 73 ms
71,484 KB
testcase_26 AC 77 ms
76,108 KB
testcase_27 AC 86 ms
76,788 KB
testcase_28 WA -
testcase_29 AC 88 ms
76,768 KB
testcase_30 AC 81 ms
76,328 KB
testcase_31 AC 73 ms
71,356 KB
testcase_32 WA -
testcase_33 AC 87 ms
76,720 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 84 ms
76,668 KB
testcase_39 WA -
testcase_40 AC 99 ms
76,460 KB
testcase_41 AC 88 ms
76,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split(' ')))
M = int(input())
B = list(map(int, input().split(' ')))

sum = [0 for _ in range(1<<N)]
for i in range(1<<N):
    for j in range(N):
        if i & (1<<j):
            sum[i] = sum[i] + A[j]

dp = []
for i in range(M+1):
    dp.append([False for _ in range(1<<N)])

dp[0][0] = True

for i in range(M):
    for j in range(1<<N):
        if sum[j] <= B[i]:
            for k in range(1<<N):
                if dp[i][k]:
                    dp[i+1][j|k] = True

answer = -1
for i in range(M+1):
    if dp[i][(1<<N)-1]:
        answer = i
        break
print(answer)    
0