結果

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

ソースコード

diff #

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