結果

問題 No.50 おもちゃ箱
ユーザー roiti46roiti46
提出日時 2015-02-23 17:05:28
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 489 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 77,588 KB
実行使用メモリ 79,244 KB
最終ジャッジ日時 2023-09-06 03:16:59
合計ジャッジ時間 15,946 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 74 ms
76,220 KB
testcase_04 WA -
testcase_05 AC 501 ms
78,768 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 72 ms
76,304 KB
testcase_09 WA -
testcase_10 AC 73 ms
76,252 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 74 ms
76,248 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 126 ms
78,700 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 748 ms
78,796 KB
testcase_31 AC 74 ms
76,224 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 881 ms
78,736 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
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
        if j+1 >= ans: break
print ans if ans < 100 else -1
    
0