結果

問題 No.505 カードの数式2
ユーザー MaxMellonMaxMellon
提出日時 2017-07-03 04:14:34
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 582 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 226,236 KB
最終ジャッジ日時 2024-04-15 13:22:09
合計ジャッジ時間 4,021 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
17,920 KB
testcase_01 AC 104 ms
12,928 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

gets
arr = gets.chomp.split.map(&:to_i)

dp = {}
dp[0] = {}
dp[0][0] = arr[0]

dp[1] = {}
dp[1][0] = dp[0][0] + arr[1]
dp[1][1] = dp[0][0] - arr[1]
dp[1][2] = dp[0][0] * arr[1]
dp[1][3] = dp[0][0] / arr[1]

2.upto(arr.length - 1) do |i|
  dp[i] = {}
  c = 0
  0.upto(dp[i - 1].length- 1) do |j|
    dp[i][c] = dp[i - 1][j] + arr[i]
    c += 1
    dp[i][c] = dp[i - 1][j] - arr[i]
    c += 1
    dp[i][c] = dp[i - 1][j] * arr[i]
    c += 1
    dp[i][c] = dp[i - 1][j] / arr[i]
    c += 1
  end
end

max = -0xFFFFFFFFF
dp[arr.length - 1].map { |k| max = k[1] if max < k[1] }
puts max
0