結果
| 問題 | 
                            No.1021 Children in Classrooms
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-04-10 23:15:50 | 
| 言語 | Kotlin  (2.1.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 912 ms / 2,000 ms | 
| コード長 | 1,072 bytes | 
| コンパイル時間 | 13,319 ms | 
| コンパイル使用メモリ | 445,580 KB | 
| 実行使用メモリ | 95,008 KB | 
| 最終ジャッジ日時 | 2024-09-16 00:21:05 | 
| 合計ジャッジ時間 | 27,821 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
コンパイルメッセージ
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() }
            ^
            
            ソースコード
@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)
}