#K92752. Counting Consecutive Increasing Temperature Days
Counting Consecutive Increasing Temperature Days
Counting Consecutive Increasing Temperature Days
Given a sequence of daily temperatures, you are required to compute, for each day, the number of consecutive previous days with strictly increasing temperatures.
Formally, let \(T = [T_1, T_2, \dots, T_n]\) be a sequence of temperatures. You need to construct an array \(C\) such that:
- \(C_1 = 0\).
- For \(i \ge 2\), \(C_i = \begin{cases} C_{i-1}+1 & \text{if } T_i > T_{i-1} \\ 0 & \text{otherwise} \end{cases}\).
For example, if the input temperatures are [30, 35, 33, 34, 38, 40]
, the output should be [0, 1, 0, 1, 2, 3]
.
inputFormat
The input is read from standard input (stdin) and has the following format:
- An integer \(n\) representing the number of days.
- A line containing \(n\) space-separated integers representing the daily temperatures.
outputFormat
The output should be printed to standard output (stdout) as \(n\) space-separated integers representing the computed counts for each day.
## sample6
30 35 33 34 38 40
0 1 0 1 2 3