結果

問題 No.1021 Children in Classrooms
ユーザー 炭酸水炭酸水
提出日時 2022-05-17 22:00:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,109 bytes
コンパイル時間 904 ms
コンパイル使用メモリ 10,772 KB
実行使用メモリ 31,104 KB
最終ジャッジ日時 2023-10-13 23:31:28
合計ジャッジ時間 4,893 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,192 KB
testcase_01 AC 16 ms
7,740 KB
testcase_02 WA -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 19 ms
8,520 KB
testcase_08 AC 19 ms
8,408 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 276 ms
25,348 KB
testcase_16 AC 283 ms
25,476 KB
testcase_17 AC 271 ms
27,224 KB
testcase_18 AC 327 ms
31,104 KB
testcase_19 AC 136 ms
8,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int, input().split())
a = list(map(int, input().split()))
s = input()

l = 0
r = 0
L = 0
R = 0
count = 0
count_ex = 0
ex_sw = True
for i in range(m):
    if s[i] == "L":
        l += 1
        count -= 1
        count_ex -= 1
        if L < l - r:
            L = l - r
            count = 0
        if count_ex < 0:
            count_ex = 0
    elif s[i] == "R":
        r += 1
        count += 1
        count_ex += 1
        if R < r - l:
            R = r - l
        if count_ex > n - 1:
            count_ex = n - 1

    if L + R == n - 1 and ex_sw:
        ex_sw = False
        if s[i] == "L":
            count_ex = 0
        elif s[i] == "R":
            count_ex = n - 1

if ex_sw:
    ans_L = 0
    ans_R = 0
    for i in range(L + 1):
        ans_L += a[i]
    for i in range(n - R - 1, n):
        ans_R += a[i]
    ans = [0] * count 
    ans.append(ans_L)
    if a[L + 1: n - R - 1]:
        ans.append(*a[L + 1: n - R - 1])
    ans.append(ans_R)
    print(*ans)

else:
    ans_sum = 0
    for i in a:
        ans_sum += i
    ans = [0] * n
    ans[count_ex] = ans_sum
    print(*ans)
0