#C2995. Daily Temperatures

    ID: 46372 Type: Default 1000ms 256MiB

Daily Temperatures

Daily Temperatures

You are given a list of daily temperatures. For each day, determine the number of days until a warmer temperature occurs. If there is no future day for which this is possible, output 0 for that day.

For example, given the temperatures [73, 74, 75, 71, 69, 72, 76, 73], the answer is [1, 1, 4, 2, 1, 1, 0, 0].

Note: The input is provided as a list of integers representing temperatures over consecutive days. The problem requires an efficient solution that can handle large inputs (up to 10^5 days). Use the standard input (stdin) for reading input and standard output (stdout) for printing the result. Any formulas should be formatted in LaTeX, for example, nn represents the number of days.

inputFormat

The first line contains an integer nn, the number of days. The second line contains nn space-separated integers representing the daily temperatures.

outputFormat

Print a single line with nn space-separated integers where the ii-th integer is the number of days until a warmer temperature occurs for day ii. If no such day exists, print 0 for that position.## sample

8
73 74 75 71 69 72 76 73
1 1 4 2 1 1 0 0