Stock Span
The span of day i counts the consecutive days ending at i (including i) with price ≤ the price on day i. Print every day's span.
Input: the first line has N; the second line has the N prices.
Output: N integers: the span of each day.
Constraints:
- 1 ≤ N ≤ 105
- 1 ≤ pi ≤ 109
Sample Tests
Input 1
7 100 80 60 70 60 75 85
Output 1
1 1 1 2 1 4 6
Input 2
1 5
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.