結果

問題 No.393 2本の竹
ユーザー hiyokko2hiyokko2
提出日時 2016-07-30 19:50:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 669 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 117,248 KB
最終ジャッジ日時 2024-04-24 13:13:02
合計ジャッジ時間 4,673 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def rec(i, r1):
	if dp[i][r1] != -1:
		return dp[i][r1]
	r2 = n1 + n2 - Asum[i - 1] - r1
	if i == m:
		res = 0
	elif max(r1, r2) < A[i]:
		res = 0
	elif r1 < A[i] and A[i] < r2:
		res = rec(i + 1, r1) + 1
	elif r2 < A[i] and A[i] < r1:
		res = rec(i + 1, r1 - A[i]) + 1
	else:
		res = max(rec(i + 1, r1), rec(i + 1, r1 - A[i])) + 1
	dp[i][r1] = res
	return res

d = int(input())
for _ in range(d):
	n1, n2 = map(int, input().split())
	m = int(input())
	A = sorted(map(int, input().split()))

	Asum = []
	Asum.append(A[0])
	for i in range(1, m):
		Asum.append(Asum[i - 1] + A[i])
	#print(Asum)
	dp = [[-1 for r1 in range(100001)] for i in range(61)]
	print(rec(0, n1))

0