結果

問題 No.50 おもちゃ箱
ユーザー convexineqconvexineq
提出日時 2020-12-06 04:51:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 684 ms / 5,000 ms
コード長 483 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 81,548 KB
実行使用メモリ 75,260 KB
最終ジャッジ日時 2023-10-17 05:40:05
合計ジャッジ時間 13,692 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
59,604 KB
testcase_01 AC 454 ms
74,880 KB
testcase_02 AC 46 ms
59,596 KB
testcase_03 AC 46 ms
53,376 KB
testcase_04 AC 40 ms
53,376 KB
testcase_05 AC 465 ms
74,868 KB
testcase_06 AC 99 ms
75,040 KB
testcase_07 AC 39 ms
53,376 KB
testcase_08 AC 40 ms
53,376 KB
testcase_09 AC 38 ms
53,376 KB
testcase_10 AC 39 ms
53,376 KB
testcase_11 AC 41 ms
53,376 KB
testcase_12 AC 43 ms
53,376 KB
testcase_13 AC 40 ms
53,376 KB
testcase_14 AC 46 ms
59,404 KB
testcase_15 AC 40 ms
53,376 KB
testcase_16 AC 54 ms
59,604 KB
testcase_17 AC 684 ms
75,088 KB
testcase_18 AC 109 ms
75,064 KB
testcase_19 AC 486 ms
75,032 KB
testcase_20 AC 54 ms
63,888 KB
testcase_21 AC 91 ms
74,880 KB
testcase_22 AC 435 ms
74,884 KB
testcase_23 AC 75 ms
75,056 KB
testcase_24 AC 39 ms
53,376 KB
testcase_25 AC 38 ms
53,376 KB
testcase_26 AC 48 ms
61,644 KB
testcase_27 AC 91 ms
74,868 KB
testcase_28 AC 417 ms
75,076 KB
testcase_29 AC 412 ms
74,888 KB
testcase_30 AC 369 ms
74,876 KB
testcase_31 AC 39 ms
53,376 KB
testcase_32 AC 471 ms
75,104 KB
testcase_33 AC 445 ms
75,128 KB
testcase_34 AC 398 ms
74,880 KB
testcase_35 AC 457 ms
75,032 KB
testcase_36 AC 511 ms
75,028 KB
testcase_37 AC 529 ms
75,260 KB
testcase_38 AC 481 ms
75,052 KB
testcase_39 AC 434 ms
74,880 KB
testcase_40 AC 414 ms
74,872 KB
testcase_41 AC 466 ms
74,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
*a, = map(int,input().split())
m = int(input())
*b, = map(int,input().split())

b.sort(reverse=True)
ans = INF = 100
from itertools import permutations
for lst in permutations(a):
    v = idx = 0
    for ai in lst:
        if v+ai > b[idx]:
            v = ai
            idx += 1
            if idx >= m or b[idx] < ai:
                idx = INF
        else:
            v += ai
        if idx >= ans: break
    ans = min(ans,idx)

print(ans+1 if ans!=INF else -1)
0