結果

問題 No.50 おもちゃ箱
ユーザー convexineqconvexineq
提出日時 2020-12-06 04:51:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 525 ms / 5,000 ms
コード長 483 bytes
コンパイル時間 678 ms
コンパイル使用メモリ 82,056 KB
実行使用メモリ 75,928 KB
最終ジャッジ日時 2024-09-17 04:20:06
合計ジャッジ時間 10,745 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
61,516 KB
testcase_01 AC 443 ms
74,868 KB
testcase_02 AC 46 ms
60,164 KB
testcase_03 AC 39 ms
52,332 KB
testcase_04 AC 39 ms
52,272 KB
testcase_05 AC 435 ms
75,104 KB
testcase_06 AC 96 ms
75,148 KB
testcase_07 AC 38 ms
53,404 KB
testcase_08 AC 38 ms
54,116 KB
testcase_09 AC 38 ms
52,408 KB
testcase_10 AC 38 ms
52,240 KB
testcase_11 AC 38 ms
52,340 KB
testcase_12 AC 38 ms
53,364 KB
testcase_13 AC 39 ms
53,624 KB
testcase_14 AC 44 ms
58,312 KB
testcase_15 AC 38 ms
52,132 KB
testcase_16 AC 48 ms
60,964 KB
testcase_17 AC 374 ms
75,496 KB
testcase_18 AC 84 ms
75,272 KB
testcase_19 AC 480 ms
75,044 KB
testcase_20 AC 54 ms
63,644 KB
testcase_21 AC 91 ms
75,144 KB
testcase_22 AC 435 ms
75,124 KB
testcase_23 AC 78 ms
75,380 KB
testcase_24 AC 39 ms
51,884 KB
testcase_25 AC 37 ms
53,284 KB
testcase_26 AC 48 ms
61,096 KB
testcase_27 AC 88 ms
75,064 KB
testcase_28 AC 412 ms
75,184 KB
testcase_29 AC 401 ms
75,200 KB
testcase_30 AC 363 ms
75,204 KB
testcase_31 AC 41 ms
52,196 KB
testcase_32 AC 460 ms
75,192 KB
testcase_33 AC 438 ms
75,928 KB
testcase_34 AC 391 ms
74,940 KB
testcase_35 AC 449 ms
75,536 KB
testcase_36 AC 500 ms
75,300 KB
testcase_37 AC 525 ms
75,376 KB
testcase_38 AC 474 ms
75,336 KB
testcase_39 AC 428 ms
74,864 KB
testcase_40 AC 404 ms
75,064 KB
testcase_41 AC 461 ms
75,152 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