#P2947. [USACO09MAR] Look Up S
[USACO09MAR] Look Up S
Description
Farmer John's cows, conveniently numbered to , are once again standing in a row. Cow has height .
Each cow is looking to her right toward those with higher index numbers. We say that cow "looks up to" cow if and . For each cow , FJ would like to know the index of the first cow in line "looked up to" by cow .
Note: about of the test data will have .
Input Format
Line : A single integer: .
Lines to : Line contains the single integer: .
Output Format
Lines to : Line contains a single integer representing the smallest index of a cow up to which cow looks. If no such cow exists, print .
6
3
2
6
1
1
2
3
3
0
6
6
0
Hint
FJ has six cows of heights , , , , , and .
Cows and both look up to cow ; cows and both look up to cow . Cows and do not look up to any cow.
京公网安备 11011102002149号