結果

問題 No.1021 Children in Classrooms
ユーザー 👑 rin204rin204
提出日時 2020-08-13 12:42:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 771 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 30,620 KB
最終ジャッジ日時 2024-04-18 01:28:15
合計ジャッジ時間 9,487 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 32 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 38 ms
10,880 KB
testcase_04 AC 38 ms
11,008 KB
testcase_05 AC 38 ms
11,008 KB
testcase_06 AC 38 ms
11,008 KB
testcase_07 AC 39 ms
11,008 KB
testcase_08 AC 39 ms
11,136 KB
testcase_09 AC 671 ms
30,260 KB
testcase_10 AC 672 ms
30,240 KB
testcase_11 AC 693 ms
30,268 KB
testcase_12 AC 687 ms
30,264 KB
testcase_13 AC 690 ms
30,140 KB
testcase_14 AC 687 ms
30,400 KB
testcase_15 AC 563 ms
25,532 KB
testcase_16 AC 599 ms
25,728 KB
testcase_17 AC 580 ms
26,324 KB
testcase_18 AC 771 ms
30,620 KB
testcase_19 AC 286 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
alst = list(map(int, input().split()))
s = input()
total = 0
max_pos = 0
min_pos = 0
pos_start = 0
pos_end = n - 1
for ss in s:
    if ss == "L":
        total -= 1
        min_pos = min(min_pos, total)
        pos_start = max(pos_start - 1, 0)
        pos_end = max(pos_end - 1, 0)
    else:
        total += 1
        max_pos = max(max_pos, total)
        pos_start = min(pos_start + 1, n - 1)
        pos_end = min(pos_end + 1, n - 1)
ans = [0 for _ in range(n)]
for i, num in enumerate(alst):
    pos = max(pos_start, i + total)
    pos = min(pos_end, pos)
    ans[pos] += num
print(*ans)
    
0