結果

問題 No.1021 Children in Classrooms
ユーザー da_louisda_louis
提出日時 2020-04-10 23:05:58
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,003 bytes
コンパイル時間 17,163 ms
コンパイル使用メモリ 430,672 KB
実行使用メモリ 78,360 KB
最終ジャッジ日時 2023-10-14 04:18:57
合計ジャッジ時間 32,944 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 322 ms
57,428 KB
testcase_01 AC 324 ms
56,948 KB
testcase_02 AC 325 ms
56,996 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 387 ms
57,364 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 841 ms
78,360 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 840 ms
77,308 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 837 ms
77,744 KB
testcase_19 AC 457 ms
59,468 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:2:10: warning: parameter 'args' is never used
fun main(args: Array<String>) = p1021()
         ^
Main.kt:6:10: warning: variable 'n' is never used
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
         ^
Main.kt:6:13: warning: variable 'm' is never used
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
            ^

ソースコード

diff #

@ExperimentalStdlibApi
fun main(args: Array<String>) = p1021()

@ExperimentalStdlibApi
fun p1021() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toInt() }
    val s = readLine()!!

    val queue = ArrayDeque(aList)
    var left = 0
    var right = s.lastIndex

    for (c in s) {
        if (c == 'R') {
            if (right == s.lastIndex && queue.size >= 2) {
                queue.addLast(queue.removeLast() + queue.removeLast())
            }
            left = Math.min(left + 1, aList.lastIndex)
            right = Math.min(right + 1, aList.lastIndex)
        } else {
            if (left == 0 && queue.size >= 2) {
                queue.addFirst(queue.removeFirst() + queue.removeFirst())
            }
            left = Math.max(left - 1, 0)
            right = Math.max(right - 1, 0)
        }

    }

    val answer = (List(left) { 0 } + queue + List(aList.lastIndex - right) { 0 }).joinToString(" ")

    println(answer)
}
0