結果

問題 No.1021 Children in Classrooms
ユーザー hedwig100hedwig100
提出日時 2020-04-10 21:57:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 340 ms / 2,000 ms
コード長 1,031 bytes
コンパイル時間 1,099 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 32,380 KB
最終ジャッジ日時 2023-10-14 00:29:04
合計ジャッジ時間 5,127 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,504 KB
testcase_01 AC 20 ms
8,544 KB
testcase_02 AC 20 ms
8,532 KB
testcase_03 AC 22 ms
8,832 KB
testcase_04 AC 23 ms
8,888 KB
testcase_05 AC 22 ms
8,752 KB
testcase_06 AC 23 ms
8,888 KB
testcase_07 AC 24 ms
8,868 KB
testcase_08 AC 23 ms
8,872 KB
testcase_09 AC 340 ms
32,248 KB
testcase_10 AC 334 ms
32,260 KB
testcase_11 AC 336 ms
32,344 KB
testcase_12 AC 339 ms
32,348 KB
testcase_13 AC 339 ms
32,184 KB
testcase_14 AC 339 ms
32,380 KB
testcase_15 AC 251 ms
25,768 KB
testcase_16 AC 256 ms
26,604 KB
testcase_17 AC 260 ms
27,436 KB
testcase_18 AC 293 ms
31,452 KB
testcase_19 AC 161 ms
8,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from collections import deque
from heapq import heapify,heappush,heappop

def main():
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    s = input()
    d = 0
    r = 0
    l = 0
    lk = 0
    rk = n - 1
    for i in range(m):
        if s[i] == 'R':
            d += 1
            lk = min(lk + 1,n - 1)
            rk = min(rk + 1,n - 1)
            r = max(r,d)
        else:
            d -= 1
            lk = max(0,lk - 1)
            rk = max(0,rk - 1)
            l = min(l,d)
    
    l = -l
    ans = [0] * n
    if r + l >= n - 1:
        t = sum(a)
        ans[lk] = t
    else:
        j = lk
        for i in range(n):
            if i < l + 1:
                ans[lk] += a[i]
            elif l + 1 <= i < n - r - 1:
                j += 1
                ans[j] += a[i]
            else:
                ans[rk] += a[i]

    print(*ans)


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