結果
問題 |
No.1021 Children in Classrooms
|
ユーザー |
|
提出日時 | 2020-04-10 23:05:58 |
言語 | Kotlin (2.1.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,003 bytes |
コンパイル時間 | 14,089 ms |
コンパイル使用メモリ | 440,180 KB |
実行使用メモリ | 92,496 KB |
最終ジャッジ日時 | 2024-09-15 23:46:56 |
合計ジャッジ時間 | 28,358 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 WA * 12 |
コンパイルメッセージ
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.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) }