結果

問題 No.1021 Children in Classrooms
ユーザー timi
提出日時 2020-10-09 17:26:12
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 535 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 31,736 KB
最終ジャッジ日時 2024-07-20 06:52:20
合計ジャッジ時間 6,998 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int, input().split())
A=list(map(int, input().split()))
s=input()
c=0
cmi,cma=0,0
for i in s:
  if i=='L':
    c-=1
  else:
    c+=1
  if c<-1*(N-1):
    c+=1
  if c>(N-1):
    c-=1
  cmi=min(cmi,c)
  cma=max(cma,c)
  
cmi*=(-1)
d=0
for i in range(cmi):
  A[i+1]+=A[i]
  A[i]=0
for i in range(cma):
  A[-2-i]+=A[-1-i]
  A[-1-i]=0
if c==0:
  print(*A)
elif c>0:
  ans=[0]*c
  for i in range(N-c):
    ans.append(A[i])
  print(*ans)
else:
  c*=-1
  ans=[]
  for i in range(c,N):
    ans.append(A[i])
  ans=ans+[0]*c
  print(*ans)
0