結果

問題 No.1021 Children in Classrooms
ユーザー nadeshinonadeshino
提出日時 2020-04-10 22:07:33
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 917 bytes
コンパイル時間 5,447 ms
コンパイル使用メモリ 72,644 KB
実行使用メモリ 33,852 KB
最終ジャッジ日時 2023-10-14 00:42:00
合計ジャッジ時間 7,999 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,356 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 88 ms
33,096 KB
testcase_10 AC 89 ms
33,248 KB
testcase_11 AC 88 ms
33,852 KB
testcase_12 AC 88 ms
33,684 KB
testcase_13 AC 88 ms
32,936 KB
testcase_14 AC 87 ms
33,168 KB
testcase_15 AC 68 ms
25,244 KB
testcase_16 AC 68 ms
25,928 KB
testcase_17 AC 69 ms
25,948 KB
testcase_18 AC 88 ms
32,452 KB
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'algorithm' [UnusedImport]
/home/judge/data/code/Main.nim(1, 19) Warning: imported and not used: 'math' [UnusedImport]
/home/judge/data/code/Main.nim(1, 45) Warning: imported and not used: 'macros' [UnusedImport]

ソースコード

diff #

import algorithm, math, sequtils, strutils, macros

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

template input*(T: static[typedesc]): untyped = 
  when T is int: read().parseInt
  elif T is float: read().parseFloat
  elif T is string: read()

let N, M = input(int)
var A = @[0] & newSeqWith(N, input(int))
let S = input(string)
var lmax, rmax, now = 0
for c in S:
  case c
  of 'L':
    if now > -(N - 1):
      now -= 1
    lmax = max(lmax, -now)
  of 'R':
    if now < N - 1:
      now += 1
    rmax = max(rmax, now)
  else:
    discard
for i in 1 .. lmax:
  A[i + 1] += A[i]
  A[i] = 0
for i in 1 .. rmax:
  A[^(i + 1)] += A[^i]
  A[^i] = 0
if now == 0:
  echo A[1 .. N].mapIt($it).join(" ")
elif now < 0:
  let L = -now
  echo (A[L + 1 .. N] & 0.repeat(L)).mapIt($it).join(" ")
else:
  let R = now
  echo (0.repeat(R) & A[1 .. ^(R + 1)]).mapIt($it).join(" ")
0