結果

問題 No.50 おもちゃ箱
ユーザー H3PO4H3PO4
提出日時 2020-04-22 10:15:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 629 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-19 08:53:07
合計ジャッジ時間 2,562 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 29 ms
10,752 KB
testcase_04 AC 29 ms
10,880 KB
testcase_05 AC 30 ms
10,880 KB
testcase_06 AC 30 ms
10,880 KB
testcase_07 AC 29 ms
10,752 KB
testcase_08 AC 29 ms
10,752 KB
testcase_09 AC 29 ms
10,880 KB
testcase_10 AC 29 ms
10,752 KB
testcase_11 WA -
testcase_12 AC 29 ms
10,752 KB
testcase_13 AC 29 ms
10,752 KB
testcase_14 AC 29 ms
10,752 KB
testcase_15 AC 29 ms
10,752 KB
testcase_16 AC 30 ms
10,752 KB
testcase_17 AC 31 ms
10,880 KB
testcase_18 AC 31 ms
10,752 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 30 ms
10,880 KB
testcase_22 AC 30 ms
10,880 KB
testcase_23 AC 30 ms
10,752 KB
testcase_24 AC 29 ms
10,752 KB
testcase_25 AC 29 ms
10,752 KB
testcase_26 WA -
testcase_27 AC 30 ms
10,752 KB
testcase_28 WA -
testcase_29 AC 30 ms
10,880 KB
testcase_30 AC 32 ms
10,880 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 32 ms
10,880 KB
testcase_34 AC 31 ms
10,880 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 33 ms
10,880 KB
testcase_38 AC 31 ms
10,880 KB
testcase_39 AC 31 ms
10,880 KB
testcase_40 AC 31 ms
10,880 KB
testcase_41 AC 32 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

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

for i, b in enumerate(B, 1):
    max_b = 0
    max_Ac = 0
    tmp = tuple([0] * len(A))
    it = itertools.product((0, 1), repeat=len(A))
    next(it)
    for t in it:
        A_c = tuple(itertools.compress(A, t))
        if max_b <= sum(A_c) <= b and max_Ac <= max(A_c):
            max_b = sum(A_c)
            max_Ac = max(A_c)
            tmp = t
    A = list(itertools.compress(A, (not x for x in tmp)))
    if not A:
        print(i)
        break
else:
    print(-1)
0