結果

問題 No.50 おもちゃ箱
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-18 16:21:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 510 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 76,388 KB
最終ジャッジ日時 2023-08-20 23:52:59
合計ジャッジ時間 6,058 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
75,860 KB
testcase_01 AC 101 ms
76,336 KB
testcase_02 AC 76 ms
75,972 KB
testcase_03 AC 71 ms
71,392 KB
testcase_04 AC 71 ms
71,436 KB
testcase_05 AC 80 ms
76,364 KB
testcase_06 AC 84 ms
76,016 KB
testcase_07 AC 69 ms
71,324 KB
testcase_08 AC 69 ms
71,324 KB
testcase_09 AC 70 ms
71,448 KB
testcase_10 AC 69 ms
71,396 KB
testcase_11 AC 73 ms
75,920 KB
testcase_12 AC 71 ms
71,032 KB
testcase_13 AC 70 ms
71,256 KB
testcase_14 AC 75 ms
75,876 KB
testcase_15 AC 70 ms
71,384 KB
testcase_16 AC 74 ms
76,224 KB
testcase_17 AC 91 ms
76,348 KB
testcase_18 AC 79 ms
76,168 KB
testcase_19 AC 108 ms
76,152 KB
testcase_20 AC 77 ms
76,216 KB
testcase_21 AC 83 ms
76,264 KB
testcase_22 AC 105 ms
76,112 KB
testcase_23 AC 72 ms
71,240 KB
testcase_24 AC 70 ms
71,296 KB
testcase_25 AC 69 ms
71,376 KB
testcase_26 AC 75 ms
76,092 KB
testcase_27 AC 85 ms
76,284 KB
testcase_28 AC 91 ms
76,052 KB
testcase_29 AC 100 ms
76,368 KB
testcase_30 AC 125 ms
76,388 KB
testcase_31 AC 69 ms
71,348 KB
testcase_32 AC 113 ms
76,172 KB
testcase_33 AC 111 ms
76,304 KB
testcase_34 AC 87 ms
76,056 KB
testcase_35 AC 110 ms
76,136 KB
testcase_36 AC 114 ms
76,340 KB
testcase_37 AC 87 ms
75,888 KB
testcase_38 AC 133 ms
75,888 KB
testcase_39 AC 102 ms
76,256 KB
testcase_40 AC 92 ms
76,116 KB
testcase_41 AC 138 ms
76,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
M = int(input())
B = list(map(int, input().split()))
B.sort(reverse=True)

size = [0]
for a in A: size += [s + a for s in size]

dp = [0] * (1 << N)
dp[0] = 1
ans = -1
for i, b in enumerate(B, 1):
    newDP = [0] * (1 << N)
    for S, ds in enumerate(dp):
        if ds:
            for T, sz in enumerate(size):
                if sz <= b:
                    newDP[S | T] = 1
    dp = newDP
    if dp[(1<<N) - 1]:
        ans = i
        break

print(ans)
0