結果
| 問題 |
No.1021 Children in Classrooms
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-04-10 21:26:43 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 305 ms / 2,000 ms |
| コード長 | 718 bytes |
| コンパイル時間 | 386 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 29,328 KB |
| 最終ジャッジ日時 | 2024-09-15 19:02:26 |
| 合計ジャッジ時間 | 4,625 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque
N, M = map(int, readline().split())
A = deque(map(int, readline().split()))
S = read().rstrip().decode()
L = 0 # A[0] の部屋
R = N - 1 # A[-1] の部屋
for s in S:
if s == 'L':
if L:
L -= 1
R -= 1
else:
if len(A) > 1:
x = A.popleft()
A[0] += x
R -= 1
continue
if R < N - 1:
L += 1
R += 1
continue
if len(A) == 1:
continue
x = A.pop()
A[-1] += x
L += 1
nums = [0] * N
nums[L: R + 1] = A
print(*nums)
maspy