結果

問題 No.45 回転寿司
ユーザー rutilicusrutilicus
提出日時 2020-08-30 22:28:54
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 350 ms / 5,000 ms
コード長 576 bytes
コンパイル時間 11,480 ms
コンパイル使用メモリ 429,368 KB
実行使用メモリ 57,172 KB
最終ジャッジ日時 2024-04-27 13:33:02
合計ジャッジ時間 22,674 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 277 ms
57,100 KB
testcase_01 AC 279 ms
57,056 KB
testcase_02 AC 290 ms
57,080 KB
testcase_03 AC 319 ms
56,984 KB
testcase_04 AC 284 ms
57,100 KB
testcase_05 AC 286 ms
57,140 KB
testcase_06 AC 281 ms
56,912 KB
testcase_07 AC 286 ms
56,968 KB
testcase_08 AC 274 ms
57,124 KB
testcase_09 AC 282 ms
56,940 KB
testcase_10 AC 272 ms
57,080 KB
testcase_11 AC 289 ms
57,172 KB
testcase_12 AC 286 ms
57,060 KB
testcase_13 AC 276 ms
57,108 KB
testcase_14 AC 280 ms
57,120 KB
testcase_15 AC 290 ms
57,048 KB
testcase_16 AC 283 ms
57,128 KB
testcase_17 AC 350 ms
57,024 KB
testcase_18 AC 288 ms
57,012 KB
testcase_19 AC 277 ms
57,056 KB
testcase_20 AC 272 ms
57,080 KB
testcase_21 AC 275 ms
57,084 KB
testcase_22 AC 269 ms
56,904 KB
testcase_23 AC 265 ms
56,912 KB
testcase_24 AC 272 ms
56,880 KB
testcase_25 AC 283 ms
56,840 KB
testcase_26 AC 283 ms
57,084 KB
testcase_27 AC 280 ms
57,052 KB
testcase_28 AC 284 ms
57,028 KB
testcase_29 AC 295 ms
57,076 KB
testcase_30 AC 279 ms
57,028 KB
testcase_31 AC 269 ms
56,888 KB
testcase_32 AC 267 ms
57,008 KB
testcase_33 AC 285 ms
57,016 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:21:13: warning: 'appendln(Int): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
    builder.appendln(max(dp[n - 1][0], dp[n - 1][1]))
            ^

ソースコード

diff #

import java.util.ArrayDeque
import kotlin.math.max

fun main() {
    val builder = StringBuilder()

    val n = readInputLine().toInt()

    val vArr = readInputLine().split(" ").map { it.toInt() }

    // [sushi][取った:1 取らない:0]
    val dp = Array(n) { IntArray(2) }

    dp[0][1] = vArr[0]

    for (i in 1 until n) {
        dp[i][0] = max(dp[i - 1][0], dp[i - 1][1])
        dp[i][1] = dp[i - 1][0] + vArr[i]
    }

    builder.appendln(max(dp[n - 1][0], dp[n - 1][1]))

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}
0