結果

問題 No.1021 Children in Classrooms
コンテスト
ユーザー もりを
提出日時 2020-04-10 21:40:47
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 715 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,121 ms
コンパイル使用メモリ 84,736 KB
実行使用メモリ 117,632 KB
最終ジャッジ日時 2026-04-04 22:41:27
合計ジャッジ時間 3,030 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n,m = map(int,input().split())
a = list(map(int,input().split()))
s = input()

# [l, r]
l,r = 0,n-1
l_margin = 0
r_margin = 0

for com in s:
    if com == 'L':
        if l_margin:
            l_margin -= 1
            r_margin += 1
            continue
        if l + 1 >= n:
            continue
        a[l + 1] += a[l]
        a[l] = 0
        l += 1
        r_margin += 1
    else:
        if r_margin:
            r_margin -= 1
            l_margin += 1
            continue
        if r - 1 < 0:
            continue
        a[r - 1] += a[r]
        a[r] = 0
        r -= 1
        l_margin += 1
    # print(a, l, r, l_margin, r_margin)

res = [0] * l_margin
res += a[l:r+1]
res += [0] * r_margin
print(*res)
0