結果

問題 No.1021 Children in Classrooms
ユーザー 👑 SPD_9X2
提出日時 2025-07-27 16:29:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 83,008 KB
実行使用メモリ 106,856 KB
最終ジャッジ日時 2025-07-27 16:29:44
合計ジャッジ時間 4,520 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

https://yukicoder.me/problems/no/1021

端だけ管理 or deque

"""

import sys
from sys import stdin
from collections import deque

N,M = map(int,stdin.readline().split())
a = list(map(int,stdin.readline().split()))
S = input()

q = deque(a)

for c in S:

    if c == "L":

        x = q.popleft()
        y = q.popleft()
        q.appendleft(x+y)
        q.append(0)

    else:

        x = q.pop()
        y = q.pop()
        q.append(x+y)
        q.appendleft(0)

print (*q)
0