#C4020. Daily Temperatures

    ID: 47513 Type: Default 1000ms 256MiB

Daily Temperatures

Daily Temperatures

Given an array of daily temperatures, for each day determine how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, output 0 for that day. Formally, for an array (T) of length (n), for each index (i) find the smallest index (j) such that (j > i) and (T[j] > T[i]), and let the answer for day (i) be (j - i); if no such (j) exists, the answer is 0.

inputFormat

The input is given via standard input. The first line contains an integer (n) representing the number of days. The second line contains (n) space-separated integers representing the daily temperatures.

outputFormat

Output a single line to standard output containing (n) space-separated integers. The (i^{th}) integer represents the number of days after day (i) until a warmer temperature occurs. If no such day exists, output 0 for that position.## sample

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

</p>