結果

問題 No.1021 Children in Classrooms
ユーザー kohei2019kohei2019
提出日時 2022-05-15 15:44:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 108,852 KB
最終ジャッジ日時 2023-10-10 00:21:45
合計ジャッジ時間 4,731 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,400 KB
testcase_01 AC 66 ms
71,404 KB
testcase_02 AC 63 ms
71,660 KB
testcase_03 AC 91 ms
76,764 KB
testcase_04 AC 81 ms
77,052 KB
testcase_05 AC 80 ms
76,720 KB
testcase_06 AC 80 ms
76,856 KB
testcase_07 AC 82 ms
76,932 KB
testcase_08 AC 81 ms
76,872 KB
testcase_09 AC 148 ms
107,072 KB
testcase_10 AC 146 ms
107,252 KB
testcase_11 AC 150 ms
107,032 KB
testcase_12 AC 152 ms
107,232 KB
testcase_13 AC 157 ms
107,064 KB
testcase_14 AC 152 ms
107,056 KB
testcase_15 AC 133 ms
101,636 KB
testcase_16 AC 130 ms
101,104 KB
testcase_17 AC 129 ms
101,568 KB
testcase_18 AC 139 ms
108,852 KB
testcase_19 AC 80 ms
76,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
lsA = list(map(int,input().split()))
S = input()
l = 0
r = 0
c = 0
for i in range(M):
    if S[i] == 'L':
        c -= 1
        l = min(l,c)
    else:
        c += 1
        r = max(r,c)
ans = [0]*N
l = abs(l)
if r+l >= N-1:
    ans[0] = sum(lsA)
else:
    ans = lsA[:]
    for i in range(l):
        ans[i+1] += ans[i]
        ans[i] = 0
    for i in range(N-1,N-1-r,-1):
        ans[i-1] += ans[i]
        ans[i] = 0
    ind = 0
    while ans[ind] == 0:
        ind += 1
    ans = ans[ind:]+[0]*ind
ind = 0
for i in range(M):
    if S[i] == 'L':
        ind = max(ind-1,0)
    else:
        ind = min(N-1,ind+1)

ans = [0]*ind+ans[:]

print(*ans[:N])
0