結果

問題 No.1021 Children in Classrooms
ユーザー takakintakakin
提出日時 2020-05-23 20:34:29
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 463 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 31,096 KB
最終ジャッジ日時 2023-07-30 07:56:33
合計ジャッジ時間 6,654 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,264 KB
testcase_01 AC 16 ms
8,208 KB
testcase_02 AC 17 ms
8,208 KB
testcase_03 AC 21 ms
8,016 KB
testcase_04 AC 21 ms
8,520 KB
testcase_05 AC 21 ms
8,060 KB
testcase_06 AC 20 ms
8,472 KB
testcase_07 AC 21 ms
8,588 KB
testcase_08 AC 21 ms
8,536 KB
testcase_09 AC 455 ms
30,860 KB
testcase_10 AC 450 ms
30,696 KB
testcase_11 AC 445 ms
30,788 KB
testcase_12 AC 455 ms
30,868 KB
testcase_13 AC 449 ms
30,852 KB
testcase_14 AC 463 ms
30,756 KB
testcase_15 AC 325 ms
25,324 KB
testcase_16 AC 319 ms
25,380 KB
testcase_17 AC 333 ms
27,416 KB
testcase_18 AC 353 ms
31,096 KB
testcase_19 AC 161 ms
8,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
A=[int(i) for i in input().split()]
S=input()
ct1,ct2,ct3=0,0,0
chk=False
for s in S:
  if s=="L":
    if ct1==-(n-1):
      chk=True
      last="l"
      continue
    else:
      ct1-=1
  else:
    if ct1==n-1:
      chk=True
      last="r"
      continue
    else:
      ct1+=1
  if ct1==-(n-1):
    last="l"
  if ct1==n-1:
    last="r"
  ct2=max(ct1,ct2)
  ct3=min(ct1,ct3)
Ans=[0]*n
if chk:
  if last=="l":
    Ans[min(n-1,ct1+n-1)]+=sum(A)
  else:
    Ans[max(0,ct1)]+=sum(A)
else:
  for i in range(n):
    if i<abs(ct3):
      Ans[abs(ct3)+ct1]+=A[i]
    elif i>=n-ct2:
      Ans[n-1-ct2+ct1]+=A[i]
    else:
      Ans[i+ct1]+=A[i]
print(*Ans)
0