結果

問題 No.1021 Children in Classrooms
ユーザー kimiyukikimiyuki
提出日時 2020-04-10 22:05:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 278 ms / 2,000 ms
コード長 1,176 bytes
コンパイル時間 451 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 31,812 KB
最終ジャッジ日時 2023-10-14 00:38:28
合計ジャッジ時間 5,186 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
9,792 KB
testcase_01 AC 32 ms
9,752 KB
testcase_02 AC 32 ms
9,724 KB
testcase_03 AC 34 ms
10,108 KB
testcase_04 AC 35 ms
10,168 KB
testcase_05 AC 34 ms
9,968 KB
testcase_06 AC 35 ms
10,048 KB
testcase_07 AC 36 ms
10,076 KB
testcase_08 AC 35 ms
10,120 KB
testcase_09 AC 277 ms
31,696 KB
testcase_10 AC 278 ms
31,656 KB
testcase_11 AC 277 ms
31,780 KB
testcase_12 AC 276 ms
31,796 KB
testcase_13 AC 274 ms
31,788 KB
testcase_14 AC 274 ms
31,680 KB
testcase_15 AC 208 ms
26,204 KB
testcase_16 AC 223 ms
26,464 KB
testcase_17 AC 213 ms
27,316 KB
testcase_18 AC 265 ms
31,812 KB
testcase_19 AC 86 ms
10,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
from typing import *

def solve(n: int, m: int, a: List[int], s: str) -> Any:
    l = 0
    r = n
    cnt_l = 0
    cnt_r = 0
    for c in s:
        if c == 'L':
            if l == 0:
                cnt_l += 1
            else:
                l -= 1
            r = max(1, r - 1)
        elif c == 'R':
            l = min(n - 1, l + 1)
            if r == n:
                cnt_r += 1
            else:
                r += 1
        else:
            assert False
    b = [0] * n
    for i in range(n):
        if i < cnt_l:
            b[l] += a[i]
        elif cnt_l <= i and i < n - cnt_r:
            b[l + i - cnt_l] += a[i]
        else:
            b[r - 1] += a[i]
    return b

# generated by online-judge-template-generator (https://github.com/kmyk/online-judge-template-generator)
def main():
    import sys
    tokens = iter(sys.stdin.read().split())
    N = int(next(tokens))
    M = int(next(tokens))
    a = [None for _ in range(N)]
    for i in range(N):
        a[i] = int(next(tokens))
    S = next(tokens)
    assert next(tokens, None) is None
    ans = solve(N, M, a, S)
    print(*ans)

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