結果

問題 No.1021 Children in Classrooms
ユーザー ikdikd
提出日時 2020-04-12 13:34:38
言語 Nim
(2.0.2)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 5,847 ms
コンパイル使用メモリ 66,448 KB
実行使用メモリ 14,704 KB
最終ジャッジ日時 2023-10-22 01:12:33
合計ジャッジ時間 8,014 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 1 ms
4,372 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 51 ms
14,704 KB
testcase_10 AC 51 ms
14,704 KB
testcase_11 AC 51 ms
14,704 KB
testcase_12 AC 50 ms
14,632 KB
testcase_13 AC 50 ms
14,632 KB
testcase_14 AC 50 ms
14,636 KB
testcase_15 AC 39 ms
12,192 KB
testcase_16 AC 42 ms
12,220 KB
testcase_17 AC 43 ms
12,716 KB
testcase_18 AC 49 ms
14,144 KB
testcase_19 AC 8 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

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