CF91B.Queue

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 11 -st walrus stands at the end of the queue and the nn -th walrus stands at the beginning of the queue. The ii -th walrus has the age equal to aia_{i} .

The ii -th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such jj ( i<ji<j ), that ai>aja_{i}>a_{j} . The displeasure of the ii -th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the ii -th one. That is, the further that young walrus stands from him, the stronger the displeasure is.

The airport manager asked you to count for each of nn walruses in the queue his displeasure.

输入格式

The first line contains an integer nn ( 2<=n<=1052<=n<=10^{5} ) — the number of walruses in the queue. The second line contains integers aia_{i} ( 1<=ai<=1091<=a_{i}<=10^{9} ).

Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.

输出格式

Print nn numbers: if the ii -th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the ii -th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.

输入输出样例

  • 输入#1

    6
    10 8 5 3 50 45
    

    输出#1

    2 1 0 -1 0 -1 
  • 输入#2

    7
    10 4 6 3 2 8 15
    

    输出#2

    4 2 1 0 -1 -1 -1 
  • 输入#3

    5
    10 3 1 10 11
    

    输出#3

    1 0 -1 -1 -1 
首页