結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,140 KB
testcase_01 AC 32 ms
10,140 KB
testcase_02 AC 29 ms
10,140 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 33 ms
10,328 KB
testcase_06 AC 34 ms
10,392 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 363 ms
33,644 KB
testcase_10 AC 359 ms
33,616 KB
testcase_11 WA -
testcase_12 AC 373 ms
33,652 KB
testcase_13 AC 365 ms
33,644 KB
testcase_14 AC 370 ms
33,652 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 325 ms
34,532 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = max(0, now)
now = min(n-1, now)

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
    for i in range(now, n):
        ans[i] = a[i-now]

print(*ans)
0