結果

問題 No.1021 Children in Classrooms
ユーザー nagitaosunagitaosu
提出日時 2020-04-10 22:05:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 336 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 31,012 KB
最終ジャッジ日時 2023-10-14 00:39:08
合計ジャッジ時間 5,364 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,780 KB
testcase_01 AC 16 ms
7,800 KB
testcase_02 AC 17 ms
7,908 KB
testcase_03 AC 19 ms
8,428 KB
testcase_04 AC 20 ms
8,200 KB
testcase_05 AC 19 ms
8,376 KB
testcase_06 AC 19 ms
8,344 KB
testcase_07 AC 20 ms
8,376 KB
testcase_08 AC 20 ms
8,272 KB
testcase_09 AC 329 ms
30,648 KB
testcase_10 AC 332 ms
30,640 KB
testcase_11 AC 333 ms
30,636 KB
testcase_12 AC 327 ms
30,716 KB
testcase_13 AC 336 ms
30,732 KB
testcase_14 AC 335 ms
30,664 KB
testcase_15 AC 272 ms
25,356 KB
testcase_16 AC 297 ms
25,304 KB
testcase_17 AC 277 ms
26,132 KB
testcase_18 AC 326 ms
31,012 KB
testcase_19 AC 179 ms
8,568 KB
権限があれば一括ダウンロードができます

ソースコード

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