結果

問題 No.45 回転寿司
ユーザー simansiman
提出日時 2016-03-22 23:49:54
言語 Ruby
(3.3.0)
結果
AC  
実行時間 97 ms / 5,000 ms
コード長 262 bytes
コンパイル時間 50 ms
コンパイル使用メモリ 11,552 KB
実行使用メモリ 23,216 KB
最終ジャッジ日時 2023-08-27 14:38:00
合計ジャッジ時間 4,322 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
16,344 KB
testcase_01 AC 97 ms
17,840 KB
testcase_02 AC 90 ms
20,596 KB
testcase_03 AC 90 ms
21,476 KB
testcase_04 AC 86 ms
18,196 KB
testcase_05 AC 87 ms
15,332 KB
testcase_06 AC 86 ms
17,336 KB
testcase_07 AC 89 ms
20,616 KB
testcase_08 AC 85 ms
15,624 KB
testcase_09 AC 89 ms
21,052 KB
testcase_10 AC 86 ms
16,736 KB
testcase_11 AC 84 ms
15,960 KB
testcase_12 AC 89 ms
20,576 KB
testcase_13 AC 85 ms
15,236 KB
testcase_14 AC 82 ms
15,020 KB
testcase_15 AC 86 ms
17,100 KB
testcase_16 AC 87 ms
15,932 KB
testcase_17 AC 85 ms
16,348 KB
testcase_18 AC 86 ms
16,092 KB
testcase_19 AC 89 ms
19,304 KB
testcase_20 AC 81 ms
15,116 KB
testcase_21 AC 82 ms
15,284 KB
testcase_22 AC 83 ms
15,036 KB
testcase_23 AC 82 ms
15,116 KB
testcase_24 AC 84 ms
15,324 KB
testcase_25 AC 83 ms
15,076 KB
testcase_26 AC 86 ms
16,780 KB
testcase_27 AC 88 ms
19,376 KB
testcase_28 AC 87 ms
17,136 KB
testcase_29 AC 88 ms
18,576 KB
testcase_30 AC 88 ms
18,880 KB
testcase_31 AC 82 ms
15,232 KB
testcase_32 AC 82 ms
15,144 KB
testcase_33 AC 90 ms
23,216 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Yukicoder
  def initialize
    n = gets.to_i
    v = gets.chomp.split.map(&:to_i)

    dp = Array.new(n, 0)
    dp[0] = v[0]
    dp[1] = v[1] || 0

    2.upto(n-1) do |i|
      dp[i] = dp[0..i-2].max + v[i]
    end

    puts dp.max
  end
end

Yukicoder.new
0