結果

問題 No.1021 Children in Classrooms
ユーザー maspymaspy
提出日時 2020-04-10 21:26:43
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 10,684 KB
実行使用メモリ 27,264 KB
最終ジャッジ日時 2023-10-13 23:10:56
合計ジャッジ時間 3,811 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,424 KB
testcase_01 AC 18 ms
8,520 KB
testcase_02 AC 17 ms
8,424 KB
testcase_03 AC 19 ms
8,612 KB
testcase_04 AC 19 ms
8,792 KB
testcase_05 AC 19 ms
8,572 KB
testcase_06 AC 20 ms
8,748 KB
testcase_07 AC 21 ms
8,788 KB
testcase_08 AC 19 ms
8,752 KB
testcase_09 AC 196 ms
26,836 KB
testcase_10 AC 193 ms
26,940 KB
testcase_11 AC 194 ms
27,068 KB
testcase_12 AC 203 ms
27,072 KB
testcase_13 AC 198 ms
27,044 KB
testcase_14 AC 197 ms
26,908 KB
testcase_15 AC 180 ms
22,280 KB
testcase_16 AC 191 ms
22,420 KB
testcase_17 AC 191 ms
23,488 KB
testcase_18 AC 225 ms
27,264 KB
testcase_19 AC 54 ms
8,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque

N, M = map(int, readline().split())
A = deque(map(int, readline().split()))
S = read().rstrip().decode()

L = 0  # A[0] の部屋
R = N - 1  # A[-1] の部屋
for s in S:
    if s == 'L':
        if L:
            L -= 1
            R -= 1
        else:
            if len(A) > 1:
                x = A.popleft()
                A[0] += x
                R -= 1
        continue
    if R < N - 1:
        L += 1
        R += 1
        continue
    if len(A) == 1:
        continue
    x = A.pop()
    A[-1] += x
    L += 1

nums = [0] * N
nums[L: R + 1] = A
print(*nums)
0