結果

問題 No.50 おもちゃ箱
ユーザー ytftytft
提出日時 2022-11-06 01:28:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,027 ms / 5,000 ms
コード長 435 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 86,852 KB
実行使用メモリ 77,488 KB
最終ジャッジ日時 2023-09-27 00:32:14
合計ジャッジ時間 32,293 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
76,472 KB
testcase_01 AC 1,876 ms
77,136 KB
testcase_02 AC 86 ms
76,672 KB
testcase_03 AC 71 ms
71,336 KB
testcase_04 AC 71 ms
71,572 KB
testcase_05 AC 953 ms
76,956 KB
testcase_06 AC 211 ms
77,192 KB
testcase_07 AC 70 ms
71,468 KB
testcase_08 AC 71 ms
71,276 KB
testcase_09 AC 70 ms
71,332 KB
testcase_10 AC 70 ms
71,588 KB
testcase_11 AC 76 ms
75,472 KB
testcase_12 AC 71 ms
71,016 KB
testcase_13 AC 72 ms
71,280 KB
testcase_14 AC 86 ms
76,532 KB
testcase_15 AC 71 ms
71,416 KB
testcase_16 AC 83 ms
76,588 KB
testcase_17 AC 1,036 ms
76,996 KB
testcase_18 AC 170 ms
76,836 KB
testcase_19 AC 1,676 ms
77,072 KB
testcase_20 AC 92 ms
76,576 KB
testcase_21 AC 214 ms
76,936 KB
testcase_22 AC 1,323 ms
76,884 KB
testcase_23 AC 137 ms
77,052 KB
testcase_24 AC 71 ms
71,492 KB
testcase_25 AC 69 ms
71,280 KB
testcase_26 AC 86 ms
76,592 KB
testcase_27 AC 223 ms
77,120 KB
testcase_28 AC 1,385 ms
77,384 KB
testcase_29 AC 1,374 ms
76,680 KB
testcase_30 AC 1,273 ms
76,996 KB
testcase_31 AC 71 ms
71,016 KB
testcase_32 AC 2,027 ms
77,488 KB
testcase_33 AC 1,802 ms
77,232 KB
testcase_34 AC 1,396 ms
77,116 KB
testcase_35 AC 1,512 ms
77,140 KB
testcase_36 AC 1,711 ms
77,300 KB
testcase_37 AC 1,264 ms
77,372 KB
testcase_38 AC 1,386 ms
76,968 KB
testcase_39 AC 1,232 ms
77,056 KB
testcase_40 AC 1,618 ms
76,992 KB
testcase_41 AC 1,479 ms
77,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,itertools
input=lambda:sys.stdin.readline().rstrip()
N=int(input())
A=list(map(int,input().split()))
M=int(input())
B=sorted(list(map(int,input().split())))[::-1]
A=itertools.permutations(A)
ans=float('inf')
for i in A:
	temp=[0 for i in range(M)]
	for j in i:
		for k in range(M):
			if temp[k]+j<=B[k]:
				temp[k]+=j
				break
		else:
			break
	else:
		ans=min(ans,M-temp.count(0))
print(ans if ans!=float('inf') else -1)
0