#abc257b. B - 1D Pawn

B - 1D Pawn

Score : 200200 points

问题描述

NN 个正方形,按照从左到右的顺序依次编号为 Square 11, Square 22, …, Square NN

同时,存在 KK 个棋子。从左边数起第 ii 个棋子最初被放在 Square AiA_i 上。

接下来,我们将对这些棋子执行 QQ 次操作。第 ii 次操作如下:

  • 如果从左边数起第 LiL_i 个棋子已经在它最右侧的正方形上,则不执行任何操作。
  • 否则,如果右侧相邻的正方形上没有棋子,则将从左边数起第 LiL_i 个棋子向右移动一个正方形;如果有棋子,则不执行任何操作。

请在所有 QQ 次操作结束后,分别输出从左边数起第 i=1,2,,Ki=1,2,\ldots,K 个棋子所在的正方形的编号。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are NN squares, indexed Square 11, Square 22, …, Square NN, arranged in a row from left to right.
Also, there are KK pieces. The ii-th piece from the left is initially placed on Square AiA_i.
Now, we will perform QQ operations against them. The ii-th operation is as follows:

  • If the LiL_i-th piece from the left is on its rightmost square, do nothing.
  • Otherwise, move the LiL_i-th piece from the left one square right if there is no piece on the next square on the right; if there is, do nothing.

Print the index of the square on which the ii-th piece from the left is after the QQ operations have ended, for each i=1,2,,Ki=1,2,\ldots,K.

Constraints

  • 1KN2001\leq K\leq N\leq 200
  • 1A1<A2<<AKN1\leq A_1<A_2<\cdots<A_K\leq N
  • 1Q10001\leq Q\leq 1000
  • 1LiK1\leq L_i\leq K
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK QQ

A1A_1 A2A_2 \ldots AKA_K

L1L_1 L2L_2 \ldots LQL_Q

Output

Print KK integers in one line, with spaces in between. The ii-th of them should be the index of the square on which the ii-th piece from the left is after the QQ operations have ended.

Sample Input 1

5 3 5
1 3 4
3 3 1 1 2

Sample Output 1

2 4 5

At first, the pieces are on Squares 11, 33, and 44. The operations are performed against them as follows:

  • The 33-rd piece from the left is on Square 44. This is not the rightmost square, and the next square on the right does not contain a piece, so move the 33-rd piece from the left to Square 55. Now, the pieces are on Squares 11, 33, and 55.
  • The 33-rd piece from the left is on Square 55. This is the rightmost square, so do nothing. The pieces are still on Squares 11, 33, and 55.
  • The 11-st piece from the left is on Square 11. This is not the rightmost square, and the next square on the right does not contain a piece, so move the 11-st piece from the left to Square 22. Now, the pieces are on Squares 22, 33, and 55.
  • The 11-st piece from the left is on Square 22. This is not the rightmost square, but the next square on the right (Square 33) contains a piece, so do nothing. The pieces are still on Squares 22, 33, and 55.
  • The 22-nd piece from the left is on Square 33. This is not the rightmost square, and the next square on the right does not contain a piece, so move the 22-nd piece from the left to Square 44; Now, the pieces are still on Squares 22, 44, and 55.

Thus, after the QQ operations have ended, the pieces are on Squares 22, 44, and 55, so 22, 44, and 55 should be printed in this order, with spaces in between.

Sample Input 2

2 2 2
1 2
1 2

Sample Output 2

1 2

Sample Input 3

10 6 9
1 3 5 7 8 9
1 2 3 4 5 6 5 6 2

Sample Output 3

2 5 6 7 9 10

update @ 2024/3/10 10:54:59