結果

問題 No.50 おもちゃ箱
ユーザー tnodinotnodino
提出日時 2022-04-08 06:05:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 5,000 ms
コード長 548 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 64,512 KB
最終ジャッジ日時 2024-05-06 01:24:32
合計ジャッジ時間 4,162 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
59,776 KB
testcase_01 AC 81 ms
64,000 KB
testcase_02 AC 45 ms
61,184 KB
testcase_03 AC 38 ms
51,840 KB
testcase_04 AC 36 ms
51,968 KB
testcase_05 AC 62 ms
62,976 KB
testcase_06 AC 63 ms
63,872 KB
testcase_07 AC 36 ms
51,584 KB
testcase_08 AC 35 ms
52,224 KB
testcase_09 AC 34 ms
51,968 KB
testcase_10 AC 34 ms
51,584 KB
testcase_11 AC 40 ms
59,392 KB
testcase_12 AC 36 ms
52,096 KB
testcase_13 AC 35 ms
52,224 KB
testcase_14 AC 46 ms
61,312 KB
testcase_15 AC 35 ms
51,968 KB
testcase_16 AC 44 ms
61,184 KB
testcase_17 AC 84 ms
64,256 KB
testcase_18 AC 59 ms
64,000 KB
testcase_19 AC 85 ms
64,128 KB
testcase_20 AC 49 ms
61,824 KB
testcase_21 AC 61 ms
64,128 KB
testcase_22 AC 94 ms
64,000 KB
testcase_23 AC 51 ms
61,952 KB
testcase_24 AC 35 ms
51,840 KB
testcase_25 AC 34 ms
52,096 KB
testcase_26 AC 46 ms
62,080 KB
testcase_27 AC 59 ms
63,872 KB
testcase_28 AC 91 ms
64,000 KB
testcase_29 AC 106 ms
64,384 KB
testcase_30 AC 107 ms
64,000 KB
testcase_31 AC 36 ms
52,096 KB
testcase_32 AC 89 ms
64,128 KB
testcase_33 AC 95 ms
64,256 KB
testcase_34 AC 70 ms
63,744 KB
testcase_35 AC 84 ms
64,000 KB
testcase_36 AC 92 ms
64,256 KB
testcase_37 AC 85 ms
64,128 KB
testcase_38 AC 107 ms
64,256 KB
testcase_39 AC 74 ms
64,000 KB
testcase_40 AC 74 ms
64,000 KB
testcase_41 AC 102 ms
64,512 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