結果

問題 No.1021 Children in Classrooms
ユーザー norioc
提出日時 2025-02-18 00:56:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 360 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 81,972 KB
実行使用メモリ 107,460 KB
最終ジャッジ日時 2025-02-18 00:56:07
合計ジャッジ時間 3,754 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N, M = map(int, input().split())
A = list(map(int, input().split()))
S = input()

q = deque(A)
for c in S:
    if c == 'L':
        a = q.popleft()
        b = q.popleft()
        q.appendleft(a + b)
        q.append(0)
    else:
        a = q.pop()
        b = q.pop()
        q.append(a + b)
        q.appendleft(0)

print(*q)
0