Problems > Days Until Warmer

Days Until Warmer

Difficulty: 1400 3500 ms 128 MB

stack

For each day print how many days you must wait for a strictly warmer temperature (0 if it never comes).

Input: the first line has N; the second line has the N daily temperatures.

Output: N integers: the waiting days per day.

Constraints:

  • 1 ≤ N ≤ 105
  • −100 ≤ ti ≤ 100

Sample Tests

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

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.