結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,184 KB
testcase_01 AC 33 ms
10,184 KB
testcase_02 AC 31 ms
10,184 KB
testcase_03 AC 32 ms
10,380 KB
testcase_04 AC 33 ms
10,448 KB
testcase_05 AC 34 ms
10,376 KB
testcase_06 AC 32 ms
10,440 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 358 ms
32,708 KB
testcase_10 AC 360 ms
32,680 KB
testcase_11 AC 364 ms
32,716 KB
testcase_12 AC 377 ms
32,716 KB
testcase_13 AC 371 ms
32,708 KB
testcase_14 AC 376 ms
32,716 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 321 ms
34,316 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:
    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