結果

問題 No.1021 Children in Classrooms
ユーザー toyuzukotoyuzuko
提出日時 2020-04-14 20:50:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 315 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 29,724 KB
最終ジャッジ日時 2024-04-09 18:08:43
合計ジャッジ時間 5,410 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 32 ms
11,008 KB
testcase_04 AC 32 ms
10,880 KB
testcase_05 AC 32 ms
10,880 KB
testcase_06 AC 32 ms
11,008 KB
testcase_07 AC 33 ms
11,136 KB
testcase_08 AC 35 ms
11,264 KB
testcase_09 AC 264 ms
29,616 KB
testcase_10 AC 266 ms
29,344 KB
testcase_11 AC 262 ms
29,496 KB
testcase_12 AC 284 ms
29,396 KB
testcase_13 AC 278 ms
29,496 KB
testcase_14 AC 284 ms
29,504 KB
testcase_15 AC 258 ms
24,880 KB
testcase_16 AC 266 ms
24,964 KB
testcase_17 AC 276 ms
25,680 KB
testcase_18 AC 315 ms
29,724 KB
testcase_19 AC 88 ms
11,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

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

lt = 0
rt = 0

for i in range(M):
    if S[i] == 'L':
        if lt == 0:
            if len(A) == 1:
                continue
            rt += 1
            a = A.popleft()
            A[0] += a
        else:
            lt -= 1
            rt += 1
    else:
        if rt == 0:
            if len(A) == 1:
                continue
            lt += 1
            a = A.pop()
            A[-1] += a
        else:
            lt += 1
            rt -= 1
            
res = [0] * lt + list(A) + [0] * rt

print(*res)
0