C. [USACO][2009][MAR][S] Look Up

    传统题 1000ms 256MiB

[USACO][2009][MAR][S] Look Up

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again standing in a row. Cow i has height HiH_i (1 <= HiH_i <= 1,000,000).

Each cow is looking to her left toward those with higher index numbers. We say that cow i 'looks up' to cow j if i < j and HiH_i < HjH_j. For each cow i, FJ would like to know the index of the first cow in line looked up to by cow i.

Format

Input

  • Line 1: A single integer: N
  • Lines 2..N+1: Line i+1 contains the single integer: HiH_i

Output

  • Lines 1..N: Line i contains a single integer representing the smallest index of a cow up to which cow i looks. If no such cow exists, print 0.

Samples

123 500
623

Details

INPUT DETAILS:

FJ has six cows of heights 3, 2, 6, 1, 1, and 2.

OUTPUT DETAILS:

Cows 1 and 2 both look up to cow 3; cows 4 and 5 both look up to cow 6; and cows 3 and 6 do not look up to any cow.

Limitation

about 50% of the test data will have N <= 1,000.

USACO 月赛模拟赛

未参加
状态
已结束
规则
OI
题目
4
开始于
2022-3-5 8:30
结束于
2022-3-5 12:30
持续时间
4 小时
主持人
参赛人数
2