Sugoroku and Pieces
InterviewTime limit2sMemory limit512 MB
Move pieces forward one square on a 2019-square board, but block moves onto the goal or an occupied square, then report each piece's final position.
- Level
Easy3 of 10
- Topics
- Simulation, Array, Brute force
- Solved
- No attempts yet
Problem
JOI has a sugoroku board. The board consists of 2019 squares in a single row. The squares are numbered 1 through 2019 in order from the start square at the left end to the goal square at the right end.
Currently, N pieces are placed on the board. The pieces are numbered 1 through N in order from closest to the start. Piece i (1 ≤ i ≤ N) is placed on square X_i. All pieces are placed on different squares.
JOI will perform M operations. In the j-th operation (1 ≤ j ≤ M), piece A_j is advanced by one square. However, if the square it is on is the goal square, or if another piece is on the destination square, piece A_j does not advance and its position does not change.
Find the square each piece is on after all operations are finished.
Input
The input is given from standard input in the following format.
N
X_1 X_2 ... X_N
M
A_1 A_2 ... A_M
Output
Output N lines. On the i-th line (1 ≤ i ≤ N), output the number of the square that piece i is on after all operations are finished.
Constraints
- 1 ≤ N ≤ 100
- 1 ≤ X_1 < X_2 < ... < X_N ≤ 2019
- 1 ≤ M ≤ 100
- 1 ≤ A_j ≤ N (1 ≤ j ≤ M)