結果

問題 No.1021 Children in Classrooms
ユーザー yuly3
提出日時 2020-05-01 00:14:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 82,728 KB
実行使用メモリ 100,588 KB
最終ジャッジ日時 2024-12-17 23:59:20
合計ジャッジ時間 4,245 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    _, _ = map(int, rl().split())
    a = deque(map(int, rl().split()))
    S = input()
    
    for si in S:
        if si == 'L':
            tmp = a.popleft()
            a[0] += tmp
            a.append(0)
        else:
            tmp = a.pop()
            a[-1] += tmp
            a.appendleft(0)
    print(*a)


if __name__ == '__main__':
    solve()
0