#STK0000082. Nhiệt độ hằng ngày (Daily Temperatures)
Nhiệt độ hằng ngày (Daily Temperatures)
Daily Temperatures
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Given an array temperatures, where the -th element is the temperature on day , determine for each day how many days must pass before a warmer temperature occurs. If no warmer day occurs later, the answer is .
Input
The first line contains , the number of days. The second line contains the temperatures.
Output
Print integers. The -th integer is the number of days from day to the next warmer day, or .
Subtasks
- Subtask 1 (30 points): ; all other conditions are unchanged.
- Subtask 2 (70 points): , .
Examples
Input
8
73 74 75 71 69 72 76 73
Output
1 1 4 2 1 1 0 0
Explanation
The daily temperatures are .
- Day is ; day is , so the wait is day.
- Day is ; day is , so the wait is day.
- Day is ; days are , none warmer than ; day is , so the wait is days.
- Day is ; day is , while day is , so the wait is days.
- Day is ; day is , so the wait is day.
- Day is ; day is , so the wait is day.
- Day is and no later day is warmer, so its answer is .
- Day is the final day, so its answer is .
Hence the output is 1 1 4 2 1 1 0 0.