QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 512 MB

#23552. 탑

Statistiques

There are $N$ towers arranged from left to right, numbered $1$ through $N$. Their heights are all different. Each tower sends a horizontal laser beam to the left from its top. A beam is received by the first tower it encounters; it does not continue past that tower.

Find the receiving tower for every tower's beam.

For example, consider the five towers with heights $6,9,5,7,4$. The fifth tower’s beam reaches the fourth tower, whose height is $7$. The fourth and third towers’ beams both reach the second tower, whose height is $9$. No tower receives the beams from the first and second towers.

Input

The first line contains $N$ ($1\le N\le500000$). The second line contains the $N$ heights in order. Every height is an integer between $1$ and $100000000$, inclusive.

Output

Print $N$ integers in tower order: the receiving tower's number, or $0$ if no tower receives that beam.

Sample Input

5
6 9 5 7 4

Sample Output

0 0 2 2 4

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.