結果

問題 No.1021 Children in Classrooms
ユーザー ikdikd
提出日時 2020-04-12 12:41:03
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 891 bytes
コンパイル時間 7,003 ms
コンパイル使用メモリ 65,724 KB
実行使用メモリ 14,308 KB
最終ジャッジ日時 2023-10-22 01:01:18
合計ジャッジ時間 7,469 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 37 ms
11,276 KB
testcase_16 AC 37 ms
11,336 KB
testcase_17 AC 38 ms
11,712 KB
testcase_18 AC 49 ms
13,700 KB
testcase_19 AC 5 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils

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

proc main() =
  # 0, 0, ..., 0, a_1 + a_2 + ... + a_x , a_{x + 1}, a_{x + 2}, ...
  # ..., a_y + a_{y + 1} + ... + a_n, 0, 0, ..., 0

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

  var
    p = 0
    q = n - 1
    x = 0
    y = n - 1
  for c in s:
    if c == 'L':
      if p == 0:
        q = max(p, q - 1)
        y = max(x, y - 1)
      else:
        p -= 1
        q -= 1
    else:
      if q == n - 1:
        p = min(q, p + 1)
        x = min(y, x + 1)
      else:
        p += 1
        q += 1
    # echo p, " ", q, " ", x, " ", y
  var b = newSeq[int](n)
  for i in 0..<n:
    if i <= x:
      b[p] += a[i]
    elif i >= y:
      b[q] += a[i]
    else:
      b[i] = a[i]
  echo b.mapIt($it).join(" ")

main()
0