問題一覧 > 通常問題

No.1021 Children in Classrooms

レベル : / AI推定難易度 : 975 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 289
作問者 : chocorusk / テスター : ningenMe
お気に入りにしたユーザー ProblemId : 4030 / 自分の提出
問題文最終更新日: 2020-04-08 14:28:44
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 243 (順位表) の他の問題:

Problem Statement

At Yuki Elementary School, $N$ classrooms numbered $1, 2, \ldots , N$ are lined up in a horizontal row in this order from left to right. Initially, classroom $i$ ($1\leq i \leq N$) has $a_i$ children. Teacher Yuki gives $M$ commands. There are $2$ kinds of commands, type L and type R, as follows.

  • When a type L command is given, all children in classrooms other than classroom $1$ simultaneously move to the classroom immediately to the left.
  • When a type R command is given, all children in classrooms other than classroom $N$ simultaneously move to the classroom immediately to the right.
The information on the $M$ commands given by Teacher Yuki is provided as a string $S$. If $S_i$ is L, the $i$-th command is of type L, and if $S_i$ is R, the $i$-th command is of type R. Find the number of children in each classroom after the $M$ commands.

Input

$N\ M$
$a_1\ a_2\ \ldots\ a_N$
$S$

  • $2\leq N\leq 2\times 10^5$
  • $1\leq M\leq 2\times 10^5$
  • $0\leq a_i\leq 10^4$
  • $N$, $M$, $a_i$ are integers.
  • $S$ is a string of length $M$.
  • Each character of $S$ is L or R.

Output

Print $N$ integers separated by spaces. The $i$-th integer from the left ($1\leq i\leq N$) should be the number of children in classroom $i$ after the $M$ commands.

Sample

Sample 1
Input
4 3
3 1 4 1
LRR
Output
0 0 4 5

  • After the $1$st command, the numbers of children in classrooms $1, 2, 3, 4$ are $4, 4, 1, 0$, respectively.
  • After the $2$nd command, the numbers of children in classrooms $1, 2, 3, 4$ are $0, 4, 4, 1$, respectively.
  • After the $3$rd command, the numbers of children in classrooms $1, 2, 3, 4$ are $0, 0, 4, 5$, respectively.

Sample 2
Input
2 7
1 8
LLLLLLL
Output
9 0

From the $2$nd command onward, no one moves.

Sample 3
Input
5 6
314 0 1 5 9
RLRLLR
Output
0 314 1 14 0

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。