結果

問題 No.50 おもちゃ箱
ユーザー roiti46roiti46
提出日時 2015-02-23 17:15:14
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 1,129 ms / 5,000 ms
コード長 425 bytes
コンパイル時間 1,432 ms
コンパイル使用メモリ 77,276 KB
実行使用メモリ 79,544 KB
最終ジャッジ日時 2023-09-08 03:43:29
合計ジャッジ時間 19,206 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
78,696 KB
testcase_01 AC 845 ms
79,156 KB
testcase_02 AC 86 ms
79,544 KB
testcase_03 AC 77 ms
76,284 KB
testcase_04 AC 78 ms
76,496 KB
testcase_05 AC 528 ms
79,172 KB
testcase_06 AC 150 ms
79,080 KB
testcase_07 AC 76 ms
76,204 KB
testcase_08 AC 77 ms
76,264 KB
testcase_09 AC 76 ms
76,108 KB
testcase_10 AC 75 ms
76,448 KB
testcase_11 AC 78 ms
77,328 KB
testcase_12 AC 76 ms
76,504 KB
testcase_13 AC 76 ms
76,352 KB
testcase_14 AC 85 ms
79,332 KB
testcase_15 AC 74 ms
76,172 KB
testcase_16 AC 87 ms
78,964 KB
testcase_17 AC 736 ms
79,084 KB
testcase_18 AC 126 ms
79,056 KB
testcase_19 AC 823 ms
79,392 KB
testcase_20 AC 90 ms
78,936 KB
testcase_21 AC 136 ms
78,928 KB
testcase_22 AC 836 ms
79,028 KB
testcase_23 AC 109 ms
79,404 KB
testcase_24 AC 74 ms
76,172 KB
testcase_25 AC 74 ms
76,372 KB
testcase_26 AC 85 ms
78,736 KB
testcase_27 AC 134 ms
78,936 KB
testcase_28 AC 743 ms
79,268 KB
testcase_29 AC 731 ms
79,060 KB
testcase_30 AC 631 ms
79,092 KB
testcase_31 AC 75 ms
76,444 KB
testcase_32 AC 1,129 ms
79,000 KB
testcase_33 AC 714 ms
79,240 KB
testcase_34 AC 709 ms
78,972 KB
testcase_35 AC 752 ms
79,216 KB
testcase_36 AC 772 ms
79,232 KB
testcase_37 AC 773 ms
79,112 KB
testcase_38 AC 795 ms
79,008 KB
testcase_39 AC 751 ms
79,004 KB
testcase_40 AC 944 ms
79,056 KB
testcase_41 AC 736 ms
79,156 KB
権限があれば一括ダウンロードができます

ソースコード

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 = 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