結果

問題 No.1021 Children in Classrooms
ユーザー ValkyrjaValkyrja
提出日時 2020-05-13 01:01:59
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 401 ms / 2,000 ms
コード長 416 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 32,544 KB
最終ジャッジ日時 2023-10-12 05:09:18
合計ジャッジ時間 7,753 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,788 KB
testcase_01 AC 16 ms
7,728 KB
testcase_02 AC 16 ms
7,884 KB
testcase_03 AC 20 ms
8,376 KB
testcase_04 AC 22 ms
8,392 KB
testcase_05 AC 22 ms
8,300 KB
testcase_06 AC 20 ms
8,408 KB
testcase_07 AC 21 ms
8,336 KB
testcase_08 AC 25 ms
8,448 KB
testcase_09 AC 386 ms
31,632 KB
testcase_10 AC 387 ms
31,688 KB
testcase_11 AC 390 ms
31,752 KB
testcase_12 AC 388 ms
31,748 KB
testcase_13 AC 401 ms
31,644 KB
testcase_14 AC 389 ms
31,648 KB
testcase_15 AC 342 ms
25,136 KB
testcase_16 AC 346 ms
26,152 KB
testcase_17 AC 344 ms
26,692 KB
testcase_18 AC 377 ms
32,544 KB
testcase_19 AC 245 ms
8,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
a=[int(j) for j in input().split()]
s=input()
l,r=0,0
p,q,tmp=0,0,0
for i in s:
    if i=="L":
        r=min(n-1,r+1)
        l=max(0,l-1)
        tmp-=1
        p=max(p,-tmp)
    else:
        l=min(n-1,l+1)
        r=max(0,r-1)
        tmp+=1
        q=max(q,tmp)

if p+q>=n:
    ans=[0]*l+[sum(a)]+[0]*r
else:
    ans=[0]*l+[sum(a[:p+1])]+a[p+1:-q-1]+[sum(a[-q-1:])]+[0]*r
print(*ans)
0