結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー | rutilicus |
提出日時 | 2020-10-16 01:25:06 |
言語 | Kotlin (1.9.23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,634 bytes |
コンパイル時間 | 20,197 ms |
コンパイル使用メモリ | 428,924 KB |
実行使用メモリ | 53,228 KB |
最終ジャッジ日時 | 2023-09-28 01:37:52 |
合計ジャッジ時間 | 28,105 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 264 ms
52,932 KB |
testcase_01 | AC | 267 ms
52,756 KB |
testcase_02 | AC | 272 ms
52,884 KB |
testcase_03 | AC | 268 ms
52,752 KB |
testcase_04 | AC | 272 ms
52,880 KB |
testcase_05 | AC | 269 ms
53,036 KB |
testcase_06 | AC | 268 ms
52,784 KB |
testcase_07 | AC | 268 ms
52,992 KB |
testcase_08 | AC | 266 ms
52,828 KB |
testcase_09 | AC | 263 ms
53,168 KB |
testcase_10 | AC | 274 ms
52,576 KB |
testcase_11 | AC | 268 ms
52,716 KB |
testcase_12 | AC | 269 ms
52,732 KB |
testcase_13 | AC | 265 ms
52,912 KB |
testcase_14 | AC | 267 ms
52,924 KB |
testcase_15 | AC | 270 ms
52,724 KB |
testcase_16 | AC | 267 ms
52,728 KB |
testcase_17 | AC | 267 ms
53,000 KB |
testcase_18 | AC | 271 ms
52,880 KB |
testcase_19 | AC | 269 ms
52,784 KB |
testcase_20 | AC | 270 ms
53,164 KB |
testcase_21 | AC | 274 ms
52,784 KB |
testcase_22 | AC | 271 ms
52,864 KB |
testcase_23 | AC | 267 ms
53,192 KB |
testcase_24 | AC | 274 ms
53,032 KB |
testcase_25 | AC | 274 ms
52,700 KB |
testcase_26 | AC | 267 ms
52,908 KB |
testcase_27 | AC | 263 ms
53,020 KB |
testcase_28 | AC | 272 ms
53,140 KB |
testcase_29 | AC | 269 ms
52,864 KB |
testcase_30 | AC | 262 ms
52,964 KB |
testcase_31 | WA | - |
testcase_32 | AC | 263 ms
53,120 KB |
testcase_33 | AC | 263 ms
52,792 KB |
testcase_34 | AC | 260 ms
52,872 KB |
testcase_35 | AC | 266 ms
52,704 KB |
testcase_36 | AC | 267 ms
52,732 KB |
testcase_37 | AC | 267 ms
53,144 KB |
testcase_38 | AC | 266 ms
52,732 KB |
testcase_39 | AC | 269 ms
52,924 KB |
testcase_40 | AC | 265 ms
52,756 KB |
testcase_41 | AC | 272 ms
52,872 KB |
testcase_42 | AC | 275 ms
52,820 KB |
testcase_43 | AC | 270 ms
52,752 KB |
testcase_44 | AC | 268 ms
53,228 KB |
testcase_45 | AC | 277 ms
52,792 KB |
testcase_46 | AC | 273 ms
52,564 KB |
testcase_47 | AC | 271 ms
52,880 KB |
testcase_48 | AC | 267 ms
52,772 KB |
コンパイルメッセージ
Main.kt:42: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(ans) ^
ソースコード
import kotlin.math.max fun main() { val builder = StringBuilder() val d = readInputLine().toInt() val c = readInputLine() + readInputLine() val runLength = runLength(c).toMutableList() if (runLength[0].first == 'x') { runLength[0] = runLength[0].copy(second = 15) } else { runLength.add(0, Pair('x', 15)) } if (runLength[runLength.lastIndex].first == 'x') { runLength[runLength.lastIndex] = runLength[runLength.lastIndex].copy(second = 15) } else { runLength.add(Pair('x', 15)) } var ans = 0 val arr = runLength.toTypedArray() for ((i, p) in arr.withIndex()) { if (p.first != 'o') { continue } ans = max(ans, when(arr[i - 1].second - d) { in Int.MIN_VALUE..0 -> p.second + arr[i - 1].second + arr[i - 2].second else -> p.second + d } ) ans = max(ans, when(arr[i + 1].second - d) { in Int.MIN_VALUE..0 -> p.second + arr[i + 1].second + arr[i + 2].second else -> p.second + d } ) } builder.appendln(ans) print(builder.toString()) } fun readInputLine(): String { return readLine()!! } fun runLength(s: String): List<Pair<Char, Int>> { val ret = mutableListOf<Pair<Char, Int>>() if (s.isNotEmpty()) { var prev = s[0] var cnt = 0 for (c in s) { if (c == prev) { cnt++ } else { ret.add(Pair(prev, cnt)) prev = c cnt = 1 } } ret.add(Pair(prev, cnt)) } return ret.toList() }