結果

問題 No.50 おもちゃ箱
ユーザー roiti46
提出日時 2015-02-23 17:06:53
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 462 bytes
コンパイル時間 120 ms
コンパイル使用メモリ 76,948 KB
実行使用メモリ 78,528 KB
最終ジャッジ日時 2024-06-23 22:10:13
合計ジャッジ時間 16,133 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 16 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools as it
N = int(raw_input())
A = map(int,raw_input().split())
M = int(raw_input())
_B = sorted(map(int,raw_input().split()),reverse = True)
ans = 100
for order in it.permutations(A,N):
    B = _B[:]
    i = j = 0
    while i < N and j < M:
        if B[j] >= A[i]:
            B[j] -= A[i]
            i += 1
        else:
            j += 1
        if i == N:
            ans = min(ans, j+1)
            break
print ans if ans < 100 else -1
    
0