結果
| 問題 |
No.50 おもちゃ箱
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-22 10:15:20 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 629 bytes |
| コンパイル時間 | 94 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-10-11 01:29:45 |
| 合計ジャッジ時間 | 2,494 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 WA * 12 |
ソースコード
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)