結果
| 問題 | No.1021 Children in Classrooms |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-10 23:05:58 |
| 言語 | Kotlin (2.3.20) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,003 bytes |
| 記録 | |
| コンパイル時間 | 12,351 ms |
| コンパイル使用メモリ | 474,896 KB |
| 実行使用メモリ | 92,888 KB |
| 最終ジャッジ日時 | 2026-04-05 03:42:42 |
| 合計ジャッジ時間 | 19,715 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 12 |
ソースコード
@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)
}