結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2020-08-30 22:28:54 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 345 ms / 5,000 ms |
コード長 | 576 bytes |
コンパイル時間 | 12,640 ms |
コンパイル使用メモリ | 432,180 KB |
実行使用メモリ | 57,148 KB |
最終ジャッジ日時 | 2024-11-15 15:42:43 |
合計ジャッジ時間 | 25,355 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
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])) ^
ソースコード
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()!! }