結果

問題 No.115 遠足のおやつ
ユーザー bellangeldindonbellangeldindon
提出日時 2019-05-15 14:42:56
言語 Python2
(2.7.18)
結果
AC  
実行時間 871 ms / 5,000 ms
コード長 839 bytes
コンパイル時間 63 ms
コンパイル使用メモリ 6,504 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-08-31 00:52:29
合計ジャッジ時間 7,015 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,932 KB
testcase_01 AC 18 ms
6,708 KB
testcase_02 AC 16 ms
6,168 KB
testcase_03 AC 12 ms
6,436 KB
testcase_04 AC 425 ms
7,144 KB
testcase_05 AC 9 ms
5,852 KB
testcase_06 AC 9 ms
6,092 KB
testcase_07 AC 12 ms
5,892 KB
testcase_08 AC 15 ms
6,208 KB
testcase_09 AC 23 ms
6,252 KB
testcase_10 AC 25 ms
6,204 KB
testcase_11 AC 11 ms
6,036 KB
testcase_12 AC 15 ms
6,012 KB
testcase_13 AC 10 ms
5,860 KB
testcase_14 AC 21 ms
6,064 KB
testcase_15 AC 228 ms
6,472 KB
testcase_16 AC 372 ms
6,700 KB
testcase_17 AC 96 ms
6,164 KB
testcase_18 AC 10 ms
5,992 KB
testcase_19 AC 16 ms
5,940 KB
testcase_20 AC 18 ms
6,216 KB
testcase_21 AC 13 ms
6,068 KB
testcase_22 AC 122 ms
6,520 KB
testcase_23 AC 19 ms
6,308 KB
testcase_24 AC 112 ms
6,532 KB
testcase_25 AC 90 ms
6,360 KB
testcase_26 AC 34 ms
6,168 KB
testcase_27 AC 59 ms
6,276 KB
testcase_28 AC 35 ms
6,152 KB
testcase_29 AC 54 ms
6,236 KB
testcase_30 AC 123 ms
6,508 KB
testcase_31 AC 37 ms
6,048 KB
testcase_32 AC 268 ms
6,508 KB
testcase_33 AC 14 ms
6,076 KB
testcase_34 AC 405 ms
6,996 KB
testcase_35 AC 77 ms
6,176 KB
testcase_36 AC 94 ms
6,784 KB
testcase_37 AC 268 ms
6,568 KB
testcase_38 AC 828 ms
8,632 KB
testcase_39 AC 871 ms
8,756 KB
testcase_40 AC 12 ms
5,936 KB
testcase_41 AC 12 ms
5,888 KB
testcase_42 AC 13 ms
5,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def smaller(lst1, lst2):
	for i in range(0, len(lst1)):
		if lst1[i] < lst2[i]: return lst1
		if lst1[i] > lst2[i]: return lst2
	return lst1

N, D, K = map(int, raw_input().split())
dp = []
for i in range(0, D+1):
	lst = []
	for j in range(0, K+1):
		lst.append([False, []])
	dp.append(lst)
dp[D][K] = [True, []]
for i in range(1, N+1):
	for j in range(1, D+1):
		for k in range(1, K+1):
			if dp[j][k][0] and j-i >= 0:
				newlst = []
				for p in range(0, len(dp[j][k][1])):
					newlst.append(dp[j][k][1][p])
				newlst.append(i)
				if not dp[j-i][k-1][0]: dp[j-i][k-1] = [True, newlst]
				else:
					if smaller(newlst, dp[j-i][k-1][1]) == newlst:
						dp[j-i][k-1] = [True, newlst]
if not dp[0][0][0]: print -1
else:
	ans = str(dp[0][0][1][0])
	for i in range(1, len(dp[0][0][1])):
		ans = ans + ' ' + str(dp[0][0][1][i])
	print ans
0