結果
問題 |
No.1160 Strange Bowling
|
ユーザー |
![]() |
提出日時 | 2020-10-19 21:23:57 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 580 ms / 2,000 ms |
コード長 | 795 bytes |
コンパイル時間 | 12,220 ms |
コンパイル使用メモリ | 447,780 KB |
実行使用メモリ | 88,728 KB |
最終ジャッジ日時 | 2024-07-21 08:08:13 |
合計ジャッジ時間 | 31,429 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
コンパイルメッセージ
Main.kt:26:13: warning: 'appendln(Long): 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[0][0], dp[0][1])) ^
ソースコード
import kotlin.math.max data class Pin(val p: Long, val a: Long) fun main() { val builder = StringBuilder() val n = readInputLine().toInt() // そのラウンドで[0]: 全部倒す、[1]: aだけ倒す 場合の最大スコア val dp = Array(n) { LongArray(2) } val pin = Array(n) { val (p, a) = readInputLine().split(" ").map { it.toLong() } Pin(p, a) } dp[n - 1][0] = pin[n - 1].p dp[n - 1][1] = pin[n - 1].a for (i in n - 2 downTo 0) { dp[i][0] = max(dp[i + 1][0], dp[i + 1][1]) + pin[i].p dp[i][1] = max(dp[i + 1][0] + pin[i + 1].p, dp[i + 1][1] + pin[i + 1].a) + pin[i].a } builder.appendln(max(dp[0][0], dp[0][1])) print(builder.toString()) } fun readInputLine(): String { return readLine()!! }