結果

問題 No.1021 Children in Classrooms
ユーザー ikd
提出日時 2020-04-12 13:34:38
言語 Nim
(2.2.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 4,287 ms
コンパイル使用メモリ 66,304 KB
実行使用メモリ 14,592 KB
最終ジャッジ日時 2024-09-22 02:34:01
合計ジャッジ時間 5,911 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, deques, sequtils

let read = iterator: string {.closure.} =
  while true:
    for s in stdin.readLine.split:
      yield s

proc main() =
  let
    n, m = read().parseInt
    a = newSeqWith(n, read().parseInt)
    s = read()

  var q = initDeque[int]()
  for it in a:
    q.addLast(it)
  for c in s:
    if c == 'L':
      let
        x = q.popFirst
        y = q.popFirst
      q.addFirst(x + y)
      q.addLast(0)
    else:
      let
        x = q.popLast
        y = q.popLast
      q.addLast(x + y)
      q.addFirst(0)
  echo q.mapIt($it).join(" ")
main()
0