結果

問題 No.45 回転寿司
ユーザー komkomhkomkomh
提出日時 2019-04-04 17:59:13
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 355 ms / 5,000 ms
コード長 410 bytes
コンパイル時間 12,587 ms
コンパイル使用メモリ 445,936 KB
実行使用メモリ 60,640 KB
最終ジャッジ日時 2024-04-30 20:08:20
合計ジャッジ時間 25,740 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 343 ms
60,496 KB
testcase_01 AC 349 ms
60,552 KB
testcase_02 AC 350 ms
60,364 KB
testcase_03 AC 355 ms
60,500 KB
testcase_04 AC 346 ms
60,460 KB
testcase_05 AC 338 ms
60,284 KB
testcase_06 AC 346 ms
60,452 KB
testcase_07 AC 348 ms
60,492 KB
testcase_08 AC 348 ms
60,480 KB
testcase_09 AC 354 ms
60,340 KB
testcase_10 AC 346 ms
60,476 KB
testcase_11 AC 337 ms
60,372 KB
testcase_12 AC 350 ms
60,404 KB
testcase_13 AC 342 ms
60,344 KB
testcase_14 AC 340 ms
60,264 KB
testcase_15 AC 351 ms
60,400 KB
testcase_16 AC 346 ms
60,532 KB
testcase_17 AC 350 ms
60,504 KB
testcase_18 AC 344 ms
60,380 KB
testcase_19 AC 349 ms
60,396 KB
testcase_20 AC 336 ms
60,444 KB
testcase_21 AC 340 ms
60,492 KB
testcase_22 AC 332 ms
60,380 KB
testcase_23 AC 334 ms
60,328 KB
testcase_24 AC 330 ms
60,320 KB
testcase_25 AC 332 ms
60,352 KB
testcase_26 AC 346 ms
60,396 KB
testcase_27 AC 351 ms
60,580 KB
testcase_28 AC 349 ms
60,424 KB
testcase_29 AC 343 ms
60,416 KB
testcase_30 AC 352 ms
60,640 KB
testcase_31 AC 337 ms
60,400 KB
testcase_32 AC 341 ms
60,224 KB
testcase_33 AC 352 ms
60,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

    fun getMinusValue(targetIndex: Int): Int = if (targetIndex < 0) 0 else V[targetIndex]

    for (i in (0 until V.size)) {
        val minus2 = getMinusValue(i - 2)
        val minus3 = getMinusValue(i - 3)
        V[i] += if (minus2 > minus3) minus2 else minus3
    }
    println(V.max())
}
0