結果

問題 No.1021 Children in Classrooms
ユーザー tktk_snsntktk_snsn
提出日時 2021-08-08 19:43:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 701 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 11,868 KB
実行使用メモリ 34,180 KB
最終ジャッジ日時 2023-10-19 20:17:37
合計ジャッジ時間 5,460 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,188 KB
testcase_01 AC 29 ms
10,188 KB
testcase_02 AC 32 ms
10,188 KB
testcase_03 AC 35 ms
10,384 KB
testcase_04 AC 32 ms
10,452 KB
testcase_05 AC 33 ms
10,380 KB
testcase_06 AC 35 ms
10,444 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 363 ms
32,712 KB
testcase_10 AC 364 ms
32,684 KB
testcase_11 AC 360 ms
32,720 KB
testcase_12 AC 364 ms
32,720 KB
testcase_13 AC 368 ms
32,712 KB
testcase_14 AC 374 ms
32,720 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 327 ms
34,180 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n, m = map(int, input().split())
a = list(map(int, input().split()))
s = input()

rmax = 0
lmax = 0
now = 0
for i in s:
    if i == "L":
        now -= 1
    else:
        now += 1
    rmax = max(rmax, now)
    lmax = max(lmax, -now)
now = min(now, n-1)
now = max(now, -n)

ans = [0] * n
if rmax + lmax >= n - 1:
    now = max(0, now)
    ans[now] = sum(a)
else:
    for i in range(lmax):
        a[lmax] += a[i]
        a[i] = 0
    for i in range(rmax):
        a[n-1-rmax] += a[n-1-i]
        a[n-1-i] = 0
    if now >= 0:
        for i in range(now, n):
            ans[i] = a[i-now]
    else:
        for i in range(n+now):
            ans[i] = a[i-now]

print(*ans)
0