#5305. [USACO09MAR] Look Up S
[USACO09MAR] Look Up S
题目描述
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
Line : A single integer: .
Lines to : Line contains the single integer: .
第 行输入 ,之后 行第 行输入一个身高 。
输出格式
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 .
共 行,按顺序每行输出一只奶牛的最近仰望对象,如果没有仰望对象,输出 。
输入输出样例 #1
输入 #1
6
3
2
6
1
1
2
输出 #1
3
3
0
6
6
0
说明/提示
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.
【输入说明】 头奶牛的身高分别为 , , , , , 。
【输出说明】奶牛 , 仰望奶牛 ,奶牛 , 仰望奶牛 ,奶牛 和 没有仰望对象。
【数据规模】
对于 的数据:;
对于 的数据:;
对于 的数据:。