結果

問題 No.45 回転寿司
ユーザー くわいくわい
提出日時 2015-12-14 17:12:45
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 987 ms / 5,000 ms
コード長 495 bytes
コンパイル時間 10,561 ms
コンパイル使用メモリ 256,600 KB
実行使用メモリ 62,832 KB
最終ジャッジ日時 2023-09-11 22:47:11
合計ジャッジ時間 44,832 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 939 ms
60,936 KB
testcase_01 AC 973 ms
62,324 KB
testcase_02 AC 957 ms
62,536 KB
testcase_03 AC 987 ms
62,616 KB
testcase_04 AC 981 ms
62,748 KB
testcase_05 AC 970 ms
62,496 KB
testcase_06 AC 962 ms
62,424 KB
testcase_07 AC 981 ms
62,404 KB
testcase_08 AC 960 ms
62,392 KB
testcase_09 AC 973 ms
62,436 KB
testcase_10 AC 983 ms
62,576 KB
testcase_11 AC 979 ms
62,352 KB
testcase_12 AC 981 ms
62,476 KB
testcase_13 AC 948 ms
62,432 KB
testcase_14 AC 948 ms
62,444 KB
testcase_15 AC 954 ms
62,396 KB
testcase_16 AC 955 ms
62,540 KB
testcase_17 AC 960 ms
62,560 KB
testcase_18 AC 962 ms
62,248 KB
testcase_19 AC 979 ms
62,460 KB
testcase_20 AC 951 ms
62,348 KB
testcase_21 AC 956 ms
62,588 KB
testcase_22 AC 939 ms
62,412 KB
testcase_23 AC 938 ms
62,600 KB
testcase_24 AC 954 ms
62,772 KB
testcase_25 AC 952 ms
62,736 KB
testcase_26 AC 970 ms
62,340 KB
testcase_27 AC 973 ms
62,528 KB
testcase_28 AC 974 ms
62,804 KB
testcase_29 AC 967 ms
62,420 KB
testcase_30 AC 958 ms
62,832 KB
testcase_31 AC 938 ms
62,212 KB
testcase_32 AC 942 ms
62,476 KB
testcase_33 AC 968 ms
62,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.io.StdIn

object Main extends App {
  def proc(n: Int, v: Array[Int]): Int = {
    val dp: Array[Array[Int]] = Array.fill(n + 3, 2)(0)

    (0 until n) foreach { i =>
      dp(i + 1)(1) = (dp(i)(0) + v(i)) max dp(i)(1)
      dp(i + 2)(0) = dp(i)(0) + v(i) max dp(i + 2)(0)
      dp(i + 3)(0) = dp(i)(0) + v(i)
    }

    dp(n).max
  }

  val n: Int = StdIn.readInt()
  val v: Array[Int] = StdIn.readLine().split(" ").map(_.toInt)

  val result: Int = proc(n, v)
  println(result)
}
0