結果

問題 No.10 +か×か
ユーザー TawaraTawara
提出日時 2015-12-14 23:11:31
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 1,126 ms / 5,000 ms
コード長 303 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 77,580 KB
実行使用メモリ 284,168 KB
最終ジャッジ日時 2023-08-21 06:16:17
合計ジャッジ時間 4,315 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
76,928 KB
testcase_01 AC 73 ms
76,420 KB
testcase_02 AC 74 ms
76,424 KB
testcase_03 AC 1,090 ms
284,168 KB
testcase_04 AC 84 ms
79,144 KB
testcase_05 AC 72 ms
76,420 KB
testcase_06 AC 1,126 ms
281,936 KB
testcase_07 AC 331 ms
172,020 KB
testcase_08 AC 119 ms
91,324 KB
testcase_09 AC 100 ms
85,600 KB
testcase_10 AC 73 ms
76,212 KB
testcase_11 AC 73 ms
76,668 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