QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#16295. Dealing Cards

Statistics

In some poker games, such as Texas Hold'em, dealing cards is a delicate process. A professional dealer is generally called a croupier. Before dealing, the croupier must "burn" a card. Burning a card means moving the card currently at the top of the deck to the bottom of the deck; this is used to prevent players from guessing cards and influencing the game.

Suppose that at the beginning, the croupier takes out a new deck of cards. This deck has $N$ distinct cards, numbered from $1$ to $N$ in order. Since it is a new deck, the cards are arranged in order, starting from the top of the deck as $1, 2, \dots, N$, with card $N$ at the bottom. To deal all the cards, the croupier performs $N$ dealing operations. Before the $i$-th deal, the croupier performs $R_i$ consecutive burn operations, where $R_i$ is given by the input. What is the order in which the player receives the cards?

For example, suppose $N=4$. Initially, the order of cards in the deck is $\{1, 2, 3, 4\}$.

Suppose $R_1 = 2$. The croupier should burn two cards, moving $1$ and $2$ to the bottom of the deck, and then deal $3$ to the player. The current order of cards in the deck is $\{4, 1, 2\}$.

Suppose $R_2 = 0$. The croupier does not need to burn any cards and deals $4$ directly to the player. The current order of cards in the deck is $\{1, 2\}$.

Suppose $R_3 = 3$. The croupier burns $1, 2, 1$ in sequence, and then deals $2$ to the player. The deck now has only one card left, $1$.

Suppose $R_4 = 2$. The croupier repeats burning $1$ twice, and then deals $1$ to the player, because $1$ is the only card left in the deck.

Input

The first line contains an integer $N$, representing the number of cards.

From the second line to the $N+1$-th line, the $(i+1)$-th line contains an integer $R_i$, where $0 \le R_i < N$.

Output

From the first line to the $N$-th line: the $i$-th line contains a single integer, representing the number of the $i$-th card received by the player.

Examples

Input 1

4
2
0
3
2

Output 1

3
4
2
1

Constraints

The sizes of the ten test cases are as follows:

Test Case 1 2 3 4 5 6 7 8 9 10
$N=$ 5,000 10,000 50,000 100,000 200,000 300,000 400,000 500,000 600,000 700,000

Figure 1. Example of burn operation R1 = 2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.