結果

問題 No.1021 Children in Classrooms
ユーザー ttrttr
提出日時 2020-05-24 16:17:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 469 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 32,368 KB
最終ジャッジ日時 2023-08-02 00:53:42
合計ジャッジ時間 6,667 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,940 KB
testcase_01 AC 15 ms
7,812 KB
testcase_02 AC 14 ms
7,760 KB
testcase_03 AC 19 ms
8,384 KB
testcase_04 AC 20 ms
8,412 KB
testcase_05 AC 20 ms
8,416 KB
testcase_06 AC 19 ms
8,412 KB
testcase_07 AC 21 ms
8,164 KB
testcase_08 AC 20 ms
8,264 KB
testcase_09 AC 456 ms
31,660 KB
testcase_10 AC 469 ms
31,576 KB
testcase_11 AC 453 ms
31,624 KB
testcase_12 AC 467 ms
31,612 KB
testcase_13 AC 461 ms
31,636 KB
testcase_14 AC 466 ms
31,684 KB
testcase_15 AC 389 ms
25,208 KB
testcase_16 AC 411 ms
25,924 KB
testcase_17 AC 403 ms
26,092 KB
testcase_18 AC 458 ms
32,368 KB
testcase_19 AC 309 ms
8,580 KB
権限があれば一括ダウンロードができます

ソースコード

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