結果

問題 No.10 +か×か
ユーザー pluto77pluto77
提出日時 2017-05-21 15:32:15
言語 Python2
(2.7.18)
結果
AC  
実行時間 3,362 ms / 5,000 ms
コード長 495 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 6,676 KB
実行使用メモリ 265,988 KB
最終ジャッジ日時 2023-08-21 06:22:35
合計ジャッジ時間 11,457 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,980 KB
testcase_01 AC 12 ms
5,972 KB
testcase_02 AC 11 ms
5,976 KB
testcase_03 AC 3,362 ms
265,988 KB
testcase_04 AC 1,103 ms
34,132 KB
testcase_05 AC 12 ms
5,856 KB
testcase_06 AC 3,346 ms
264,200 KB
testcase_07 AC 1,741 ms
98,072 KB
testcase_08 AC 412 ms
23,624 KB
testcase_09 AC 637 ms
26,336 KB
testcase_10 AC 18 ms
6,160 KB
testcase_11 AC 13 ms
6,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki_10

n=int(raw_input())
t=int(raw_input())
a=map(int,raw_input().split())
dp=[['?' for i in xrange(t+1)] for j in xrange(n+1)]
dp[0][a[0]]=''
for i in xrange(n-1):
 for j in xrange(t+1):
  p=j+a[i+1]
  m=j*a[i+1]
  if dp[i][j]!='?':
   if p<=t:
    if dp[i+1][p]=='?':
     dp[i+1][p]=dp[i][j]+'+'
    else:
     dp[i+1][p]=max(dp[i+1][p],dp[i][j]+'+')
   if m<=t:
    if dp[i+1][m]=='?':
     dp[i+1][m]=dp[i][j]+'*'
    else:
     dp[i+1][m]=max(dp[i+1][m],dp[i][j]+'*')
print dp[n-1][t]
0