結果

問題 No.10 +か×か
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-01-29 21:12:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 714 ms / 5,000 ms
コード長 240 bytes
コンパイル時間 62 ms
コンパイル使用メモリ 11,492 KB
実行使用メモリ 53,772 KB
最終ジャッジ日時 2023-08-21 06:09:48
合計ジャッジ時間 4,211 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,224 KB
testcase_01 AC 83 ms
15,040 KB
testcase_02 AC 82 ms
15,092 KB
testcase_03 AC 714 ms
53,772 KB
testcase_04 AC 490 ms
40,260 KB
testcase_05 AC 80 ms
15,304 KB
testcase_06 AC 706 ms
53,672 KB
testcase_07 AC 482 ms
40,336 KB
testcase_08 AC 191 ms
22,468 KB
testcase_09 AC 281 ms
28,500 KB
testcase_10 AC 81 ms
15,516 KB
testcase_11 AC 80 ms
15,272 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
t=gets.to_i
a=gets.split.map(&:to_i)
d=Array.new(99){[]}
d[n][t]=1
(n-1).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.upto(n-1){|i|d[i+1][x+a[i]]?(print'+';x+=a[i]):(print'*';x*=a[i])}
0