結果

問題 No.1021 Children in Classrooms
ユーザー nagitaosu
提出日時 2020-04-10 22:05:44
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 428 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 30,644 KB
最終ジャッジ日時 2024-09-15 20:27:39
合計ジャッジ時間 6,165 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = [int(item) for item in input().split()]
s = input().rstrip()

left = 0; right = 0
place = 0
start_from = 0
for ch in s:
    if ch == "L":
        place -= 1
        if start_from > 0:
            start_from -= 1
    else:
        place += 1
        if start_from < n - 1:
            start_from += 1
    right = max(place, right)
    left = min(place, left)

right += 1
left = -left + 1
# Over
if right + left > n:
    arr = [sum(a)]
else:
    arr = [sum(a[:left])] + a[left:-right] + [sum(a[-right:])]

arr = [0] * start_from + arr
arr += [0] * (n - len(arr))
print(*arr)
0