結果

問題 No.1021 Children in Classrooms
ユーザー ttrttr
提出日時 2020-05-24 16:10:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 571 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 30,732 KB
最終ジャッジ日時 2024-04-20 01:26:07
合計ジャッジ時間 8,137 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 27 ms
10,752 KB
testcase_03 AC 33 ms
11,008 KB
testcase_04 AC 35 ms
11,008 KB
testcase_05 AC 34 ms
11,008 KB
testcase_06 AC 32 ms
11,136 KB
testcase_07 AC 33 ms
11,008 KB
testcase_08 AC 32 ms
11,008 KB
testcase_09 AC 585 ms
30,276 KB
testcase_10 AC 586 ms
30,252 KB
testcase_11 AC 581 ms
30,284 KB
testcase_12 AC 589 ms
30,412 KB
testcase_13 AC 581 ms
30,280 KB
testcase_14 AC 561 ms
30,408 KB
testcase_15 AC 512 ms
25,544 KB
testcase_16 AC 538 ms
25,756 KB
testcase_17 AC 516 ms
26,340 KB
testcase_18 AC 549 ms
30,732 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int, input().split())
A = [int(a) for a in input().split()]
S = input()

l = 0
r = N-1
l2 = 0
r2 = 0
for i in range(M):
    if S[i] == "L" and l2 == 0:
        l += 1
        r2 += 1
    elif S[i] == "R" and r2 == 0:
        r -= 1
        l2 += 1
    elif S[i] == "L":
        l2 -= 1
        r2 += 1
    else:
        r2 -= 1
        l2 += 1
    l2 = min(l2, N-1)
    r2 = min(r2, N-1)
    l = min(l, N-1)
    r = max(r, 0)

if l == r:
    ans = [0]*l2 + [sum(A)] + [0]*r2
else:
    ans = [0]*l2 + [sum(A[:l+1])] + A[l+1:r] + [sum(A[r:])] + [0]*r2
print(*ans)
0