結果

問題 No.50 おもちゃ箱
コンテスト
ユーザー roiti46
提出日時 2015-02-23 17:15:14
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
AC  
実行時間 677 ms / 5,000 ms
コード長 425 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,524 ms
コンパイル使用メモリ 81,200 KB
実行使用メモリ 83,304 KB
最終ジャッジ日時 2026-03-12 06:57:41
合計ジャッジ時間 11,957 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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 = M+1
for order in it.permutations(A,N):
    B = _B[:]
    i = j = 0
    while i < N and j < M:
        if B[j] >= order[i]:
            B[j] -= order[i]
            i += 1
        else:
            j += 1
    ans = min(ans, j+1)
print ans if ans < M+1 else -1
    
0