結果

問題 No.1021 Children in Classrooms
ユーザー ronpooronpoo
提出日時 2023-11-21 14:44:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 613 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 117,096 KB
最終ジャッジ日時 2023-11-21 14:44:46
合計ジャッジ時間 5,045 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,588 KB
testcase_01 AC 37 ms
53,588 KB
testcase_02 AC 34 ms
53,588 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 116 ms
117,096 KB
testcase_19 AC 48 ms
64,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
A = list(map(int, input().split()))
S = input()

cnt = 0
l, r = 0, 0
for i in range(M):
    if S[i] == 'L':
        cnt -= 1        
    else:
        cnt += 1
    if cnt < 0:
        if abs(cnt) > l:
            l += 1
    elif cnt > 0:
        if cnt > r:
            r += 1
b = [0]
r = N - r - 1
for i in range(N):
    if i <= l:
        b[-1] += A[i]
    elif l < i <= r:
        b.append(A[i])
    else:
        b[-1] += A[i]

l, r = 0, 0
for i in range(N - len(b)):
    if S[-i-1] == 'L':
        r += 1
    else:
        l += 1

ans = [0]*l + b + [0]*r
print(*ans, sep=' ')
0