結果

問題 No.10 +か×か
ユーザー TawaraTawara
提出日時 2015-12-14 23:11:13
言語 Python2
(2.7.18)
結果
AC  
実行時間 3,022 ms / 5,000 ms
コード長 303 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 6,744 KB
実行使用メモリ 52,852 KB
最終ジャッジ日時 2023-08-21 06:16:26
合計ジャッジ時間 8,032 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,048 KB
testcase_01 AC 11 ms
5,996 KB
testcase_02 AC 11 ms
5,956 KB
testcase_03 AC 2,987 ms
51,720 KB
testcase_04 AC 29 ms
8,440 KB
testcase_05 AC 11 ms
6,072 KB
testcase_06 AC 3,022 ms
52,852 KB
testcase_07 AC 783 ms
31,676 KB
testcase_08 AC 146 ms
18,512 KB
testcase_09 AC 91 ms
14,472 KB
testcase_10 AC 11 ms
5,972 KB
testcase_11 AC 11 ms
6,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
T = input()
A = map(int,raw_input().split())
dp = {A[0]:""}
for i in xrange(1,N):
	tmp_dp = {}
	for k,v in dp.iteritems():
		for nk,nv in [(k+A[i],v+"+"),(k*A[i],v+"*")]:
			if nk <= T and (nk not in tmp_dp or tmp_dp[nk] < nv):
				tmp_dp[nk] = nv
	dp = tmp_dp
print dp[T] if T in dp else -1
0