QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 512 MB

#23552. 塔

统计

$N$ 本の塔が左から右へ並んでおり、$1$ から $N$ までの番号が付いています。高さはすべて異なります。各塔は頂上から左に向かって水平なレーザー光線を発射します。光線は最初にぶつかった塔で受信され、その塔を通り抜けて進むことはありません。

各塔が発射した光線を受信する塔を求めてください。

例えば、高さが順に $6,9,5,7,4$ の5本の塔を考えます。5番目の塔の光線は、高さ $7$ の4番目の塔に届きます。4番目と3番目の塔の光線は、どちらも高さ $9$ の2番目の塔に届きます。1番目と2番目の塔の光線を受信する塔はありません。

入力

1行目には $N$($1\le N\le500000$)が与えられます。2行目には $N$ 本の塔の高さが順に与えられます。各高さは $1$ 以上 $100000000$ 以下の整数です。

出力

塔の順に $N$ 個の整数を出力してください。各整数は光線を受信する塔の番号とし、受信する塔がない場合は $0$ としてください。

入出力例

入力 1

5
6 9 5 7 4

出力 1

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.