結果

問題 No.10 +か×か
ユーザー LaLa
提出日時 2021-01-07 10:41:06
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 332 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 11,600 KB
実行使用メモリ 279,852 KB
最終ジャッジ日時 2023-08-21 06:33:29
合計ジャッジ時間 15,902 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,264 KB
testcase_01 AC 79 ms
15,372 KB
testcase_02 AC 79 ms
15,112 KB
testcase_03 TLE -
testcase_04 AC 676 ms
42,968 KB
testcase_05 AC 79 ms
15,276 KB
testcase_06 TLE -
testcase_07 AC 1,730 ms
103,368 KB
testcase_08 AC 411 ms
35,068 KB
testcase_09 AC 571 ms
36,604 KB
testcase_10 AC 83 ms
15,440 KB
testcase_11 AC 81 ms
15,276 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
t=gets.to_i
a=gets.split.map(&:to_i)

dp=Array.new(n+1){Array.new(t+1,"!")}
dp[1][a[0]]=""

(1...n).each do |x|
  (0..t).each do |y|
    next if dp[x][y]=="!"
    dp[x+1][y+a[x]]=[dp[x+1][y+a[x]],dp[x][y]+"+"].max if y+a[x] <=t
    dp[x+1][y*a[x]]=[dp[x+1][y*a[x]],dp[x][y]+"*"].max if y*a[x]<=t
  end
end

puts dp[n][t]
0