結果

問題 No.1021 Children in Classrooms
ユーザー もりをもりを
提出日時 2020-04-10 21:40:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 715 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 115,152 KB
最終ジャッジ日時 2023-10-13 23:51:10
合計ジャッジ時間 4,310 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,136 KB
testcase_01 AC 71 ms
71,088 KB
testcase_02 AC 72 ms
71,348 KB
testcase_03 AC 90 ms
76,812 KB
testcase_04 AC 84 ms
76,784 KB
testcase_05 AC 86 ms
76,852 KB
testcase_06 AC 87 ms
76,668 KB
testcase_07 AC 87 ms
76,464 KB
testcase_08 AC 87 ms
76,676 KB
testcase_09 AC 154 ms
106,608 KB
testcase_10 AC 151 ms
106,480 KB
testcase_11 AC 153 ms
106,604 KB
testcase_12 AC 163 ms
107,004 KB
testcase_13 AC 165 ms
106,732 KB
testcase_14 AC 163 ms
106,856 KB
testcase_15 AC 137 ms
100,036 KB
testcase_16 AC 138 ms
100,164 KB
testcase_17 AC 138 ms
99,988 KB
testcase_18 AC 146 ms
115,152 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

# [l, r]
l,r = 0,n-1
l_margin = 0
r_margin = 0

for com in s:
    if com == 'L':
        if l_margin:
            l_margin -= 1
            r_margin += 1
            continue
        if l + 1 >= n:
            continue
        a[l + 1] += a[l]
        a[l] = 0
        l += 1
        r_margin += 1
    else:
        if r_margin:
            r_margin -= 1
            l_margin += 1
            continue
        if r - 1 < 0:
            continue
        a[r - 1] += a[r]
        a[r] = 0
        r -= 1
        l_margin += 1
    # print(a, l, r, l_margin, r_margin)

res = [0] * l_margin
res += a[l:r+1]
res += [0] * r_margin
print(*res)
0