結果

問題 No.50 おもちゃ箱
ユーザー tnodinotnodino
提出日時 2022-04-08 06:05:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 5,000 ms
コード長 548 bytes
コンパイル時間 867 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 76,648 KB
最終ジャッジ日時 2023-08-18 19:40:40
合計ジャッジ時間 7,663 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
76,036 KB
testcase_01 AC 107 ms
76,464 KB
testcase_02 AC 71 ms
76,500 KB
testcase_03 AC 63 ms
71,404 KB
testcase_04 AC 66 ms
71,376 KB
testcase_05 AC 85 ms
76,476 KB
testcase_06 AC 86 ms
76,296 KB
testcase_07 AC 64 ms
71,372 KB
testcase_08 AC 63 ms
71,436 KB
testcase_09 AC 67 ms
71,072 KB
testcase_10 AC 63 ms
71,224 KB
testcase_11 AC 70 ms
76,048 KB
testcase_12 AC 64 ms
71,192 KB
testcase_13 AC 65 ms
71,276 KB
testcase_14 AC 73 ms
76,536 KB
testcase_15 AC 68 ms
71,276 KB
testcase_16 AC 72 ms
76,372 KB
testcase_17 AC 114 ms
76,372 KB
testcase_18 AC 94 ms
76,476 KB
testcase_19 AC 114 ms
76,468 KB
testcase_20 AC 74 ms
76,532 KB
testcase_21 AC 83 ms
76,648 KB
testcase_22 AC 106 ms
76,528 KB
testcase_23 AC 74 ms
76,412 KB
testcase_24 AC 67 ms
71,204 KB
testcase_25 AC 64 ms
71,376 KB
testcase_26 AC 74 ms
76,412 KB
testcase_27 AC 83 ms
76,540 KB
testcase_28 AC 112 ms
76,484 KB
testcase_29 AC 129 ms
76,428 KB
testcase_30 AC 130 ms
76,432 KB
testcase_31 AC 63 ms
71,364 KB
testcase_32 AC 115 ms
76,624 KB
testcase_33 AC 113 ms
76,432 KB
testcase_34 AC 94 ms
76,472 KB
testcase_35 AC 109 ms
76,468 KB
testcase_36 AC 114 ms
76,388 KB
testcase_37 AC 110 ms
76,332 KB
testcase_38 AC 136 ms
76,524 KB
testcase_39 AC 98 ms
76,336 KB
testcase_40 AC 101 ms
76,428 KB
testcase_41 AC 132 ms
76,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
M = int(input())
B = list(map(int,input().split()))
B.sort(reverse=True)
S = [0] * (1<<N)
for bit in range(1<<N):
    for i in range(N):
        if bit & (1<<i):
            S[bit] += A[i]
DP = [[0] * (1<<N) for _ in range(M+1)]
DP[0][0] = 1
for i in range(M):
    for bit in range(1<<N):
        for bit2 in range(1<<N):
            if bit & bit2 == 0 and DP[i][bit] and S[bit2] <= B[i]:
                DP[i+1][bit|bit2] = 1
    if DP[i+1][(1<<N)-1]:
        print(i+1)
        exit()
print(-1)
0