結果

問題 No.1021 Children in Classrooms
ユーザー da_louisda_louis
提出日時 2020-04-10 23:15:50
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 869 ms / 2,000 ms
コード長 1,072 bytes
コンパイル時間 15,506 ms
コンパイル使用メモリ 425,820 KB
実行使用メモリ 80,868 KB
最終ジャッジ日時 2023-10-14 04:56:02
合計ジャッジ時間 29,654 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 317 ms
57,064 KB
testcase_01 AC 318 ms
56,980 KB
testcase_02 AC 315 ms
57,060 KB
testcase_03 AC 355 ms
57,304 KB
testcase_04 AC 364 ms
57,396 KB
testcase_05 AC 362 ms
57,324 KB
testcase_06 AC 361 ms
57,260 KB
testcase_07 AC 370 ms
57,316 KB
testcase_08 AC 362 ms
57,304 KB
testcase_09 AC 855 ms
80,868 KB
testcase_10 AC 860 ms
79,004 KB
testcase_11 AC 854 ms
79,100 KB
testcase_12 AC 869 ms
77,508 KB
testcase_13 AC 856 ms
77,260 KB
testcase_14 AC 849 ms
77,940 KB
testcase_15 AC 808 ms
71,436 KB
testcase_16 AC 811 ms
70,692 KB
testcase_17 AC 812 ms
69,044 KB
testcase_18 AC 859 ms
79,520 KB
testcase_19 AC 440 ms
59,476 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.toLong() }
    val s = readLine()!!

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

    for (c in s) {
        if (c == 'R') {
            if (right == aList.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 = buildList {
        addAll(List(left) { 0 })
        addAll(queue)
        addAll(List(aList.lastIndex - right) { 0 })
    }.joinToString(" ")

    println(answer)
}
0