結果

問題 No.1021 Children in Classrooms
ユーザー rulerruler
提出日時 2020-04-11 00:18:58
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 783 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 30,296 KB
最終ジャッジ日時 2023-10-14 09:19:17
合計ジャッジ時間 3,796 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,652 KB
testcase_01 AC 18 ms
8,480 KB
testcase_02 AC 18 ms
8,628 KB
testcase_03 AC 20 ms
8,740 KB
testcase_04 AC 20 ms
8,720 KB
testcase_05 AC 19 ms
8,700 KB
testcase_06 AC 19 ms
8,828 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 213 ms
30,220 KB
testcase_10 AC 214 ms
30,096 KB
testcase_11 AC 213 ms
30,100 KB
testcase_12 AC 222 ms
30,120 KB
testcase_13 AC 220 ms
30,152 KB
testcase_14 AC 220 ms
30,136 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 240 ms
30,296 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque

n, m = map(int, sys.stdin.readline().split())
a = deque(map(int, sys.stdin.readline().split()))
s = sys.stdin.readline().rstrip()

def main():
    l = r = 0
    for c in s:
        if c == 'L':  
            if l == 0:
                if len(a) == 1:
                    continue
                b = a.popleft()
                a[0] += b
            r += 1
            l = max(0, l - 1)
        else:
            if r == 0:
                if len(a) == 0:
                    continue
                b = a.pop()
                a[-1] += b
            r = max(0, r - 1)
            l += 1
        if len(a) == 1:
            break
        
    res = [0] * l + list(a) + [0] * r
    print(*res, sep=' ')

if __name__ == '__main__':
    main()
0