結果

問題 No.45 回転寿司
ユーザー komkomh
提出日時 2019-04-04 17:11:46
言語 Kotlin
(2.1.0)
結果
AC  
実行時間 396 ms / 5,000 ms
コード長 446 bytes
コンパイル時間 14,201 ms
コンパイル使用メモリ 447,108 KB
実行使用メモリ 60,540 KB
最終ジャッジ日時 2024-11-20 17:41:03
合計ジャッジ時間 26,355 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:2:9: warning: variable 'N' is never used
    val N: Int = readLine()!!.toInt()
        ^

ソースコード

diff #

fun main() {
    val N: Int = readLine()!!.toInt()
    var V: IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray()

    fun getPlusValue(targetIndex: Int): Int {
        return if (targetIndex < V.size) V[targetIndex] else 0
    }

    for (i in (V.size - 1 downTo 0)) {
        val plus2 = getPlusValue(i + 2)
        val plus3 = getPlusValue(i + 3)
        V[i] += if (plus2 > plus3) plus2 else plus3
    }
    println(V.max())
}
0