#K79977. Days Until More Rainfall
Days Until More Rainfall
Days Until More Rainfall
Given an array of daily rainfall amounts, determine for each day the number of days until a day with strictly higher rainfall occurs. If no such day exists, output 0 for that day.
Formally, given an array \(A\) of rainfall measurements for \(n\) days, for each day \(i\) find the smallest day \(j > i\) such that \(A[j] > A[i]\) and output \(j-i\). If no such \(j\) exists, output 0.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains an integer \(n\) (\(1 \leq n \leq 10^5\)) indicating the number of days.
- The second line contains \(n\) space-separated integers representing the rainfall amounts for each day.
outputFormat
Print a single line to standard output (stdout) containing \(n\) space-separated integers. The \(i\)th integer is the number of days until a day with strictly more rainfall occurs. If no such day exists, print 0 for that day.
## sample6
2 1 1 5 3 6
3 2 1 2 1 0
</p>