結果

問題 No.1021 Children in Classrooms
ユーザー c-yan
提出日時 2020-04-11 00:49:41
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 30,744 KB
最終ジャッジ日時 2024-09-16 04:53:29
合計ジャッジ時間 5,599 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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

p = 0
for c in S:
    if c == 'L':
        p = max(p - 1, -N + 1)
        if p < 0:
            a[-p] += a[-p - 1]
            a[-p - 1] = 0
    elif c == 'R':
        p = min(p + 1, N - 1)
        if p > 0:
            a[N - 1 - p] += a[N - p]
            a[N - p] = 0

if p > 0:
    print(*([0] * p + a)[:N])
elif p < 0:
    print(*(a + [0] * -p)[-p:N - p])
else:
    print(*a)
0