結果

問題 No.1021 Children in Classrooms
コンテスト
ユーザー FromBooska
提出日時 2024-02-23 19:59:23
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 407 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 453 ms
コンパイル使用メモリ 85,044 KB
実行使用メモリ 116,464 KB
最終ジャッジ日時 2026-04-15 15:52:53
合計ジャッジ時間 7,695 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# dequeで高速にできるか

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

from collections import deque
que = deque(A)
for i in range(M):
    s = S[i]
    if s == 'L':
        num = que.popleft()
        que[0] += num
        que.append(0)
    elif s == 'R':
        num = que.pop()
        que[-1] += num
        que.appendleft(0)
    #print('que', que)
print(*que)
0