結果
問題 | No.1021 Children in Classrooms |
ユーザー |
|
提出日時 | 2020-09-02 22:39:30 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 409 ms / 2,000 ms |
コード長 | 625 bytes |
コンパイル時間 | 81 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 29,628 KB |
最終ジャッジ日時 | 2024-11-21 23:40:48 |
合計ジャッジ時間 | 6,205 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
from collections import deque n, m = map(int, input().split()) a = deque(map(int, input().split())) s = input() l = 0 r = n-1 for i in range(m): if s[i] == "L": if l - 1 < 0: if len(a) > 1: a0 = a.popleft() a1 = a.popleft() a.appendleft(a0+a1) else: l -= 1 r = max(r-1, 0) else: if r+1 > n-1: if len(a) > 1: a_1 = a.pop() a_2 = a.pop() a.append(a_1+a_2) else: r += 1 l = min(l+1, n-1) print(*[0]*l + list(a) + [0]*(n-1-r))