結果

問題 No.10 +か×か
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-02-20 22:12:12
言語 Ruby
(3.3.0)
結果
AC  
実行時間 713 ms / 5,000 ms
コード長 236 bytes
コンパイル時間 56 ms
コンパイル使用メモリ 11,496 KB
実行使用メモリ 53,820 KB
最終ジャッジ日時 2023-08-21 06:10:34
合計ジャッジ時間 4,155 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,252 KB
testcase_01 AC 85 ms
15,096 KB
testcase_02 AC 78 ms
15,072 KB
testcase_03 AC 713 ms
53,820 KB
testcase_04 AC 483 ms
40,336 KB
testcase_05 AC 80 ms
15,188 KB
testcase_06 AC 711 ms
53,764 KB
testcase_07 AC 484 ms
40,212 KB
testcase_08 AC 191 ms
22,596 KB
testcase_09 AC 284 ms
28,656 KB
testcase_10 AC 81 ms
15,504 KB
testcase_11 AC 80 ms
15,316 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

gets
t=gets.to_i
a=gets.split.map &:to_i
d=(0..n=a.size).map{[]}
d[n][t]=1
n-=1
n.downto(2){|i|1.upto(t){|x|d[i+1][x+a[i]]&&d[i][x]=1;d[i+1][x*a[i]]&&d[i][x]=1}}
x=a[0]
(1..n).map{|i|d[i+1][x+a[i]]?(print'+';x+=a[i]):(print'*';x*=a[i])}
0