#C8183. Temperature Spans
Temperature Spans
Temperature Spans
You are given the daily temperatures for n consecutive days. For each day, the temperature span is defined as the number of consecutive days (up to and including the current day) for which the temperature did not exceed the temperature on that day.
More formally, let the temperature on day \(i\) be \(T_i\). The span for day \(i\) is the maximum number \(k\) (where \(1 \leq k \leq i\)) such that \(T_{i-k+1} \leq T_{i-k+2} \leq \cdots \leq T_i\).
For example, if the temperatures are: 100 80 60 70 60 75 85
, then the spans are: 1 1 1 2 1 4 6
.
Your task is to compute the temperature span for each day.
inputFormat
The first line contains an integer \(n\) representing the number of days.
The second line contains \(n\) space-separated integers representing the temperatures of each day.
\(1 \leq n \leq 10^5\); each temperature is an integer between \(-10^9\) and \(10^9\).
outputFormat
Output a single line with \(n\) space-separated integers, where the \(i\)-th integer is the temperature span for that day.
## sample7
100 80 60 70 60 75 85
1 1 1 2 1 4 6
</p>