結果
| 問題 |
No.50 おもちゃ箱
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-03-19 05:15:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 511 bytes |
| コンパイル時間 | 565 ms |
| コンパイル使用メモリ | 82,320 KB |
| 実行使用メモリ | 76,532 KB |
| 最終ジャッジ日時 | 2025-03-19 05:15:33 |
| 合計ジャッジ時間 | 19,388 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 WA * 22 |
ソースコード
from itertools import permutations
INF = 1 << 60
N = int(input())
A = list(map(int, input().split()))
M = int(input())
B = list(map(int, input().split()))
def put(xs) -> int:
p = 0
caps = [0] * M
for x in xs:
while p < M and caps[p]+x > B[p]:
p += 1
if p == M: return -1
caps[p] += x
return p+1
ans = INF
for ps in permutations(A):
res = put(ps)
if res == -1: continue
ans = min(ans, res)
if ans == INF:
print(-1)
else:
print(ans)
norioc