13644 - DS_2022_HW2_Stack&Queue   

Description

In the past few years, due to the rise of cryptocurrencies, there has been a boom in mining cryptocurrencies. As a result, the demand for GPU increases significantly and the price of GPU also increases. Many people keep tracking the prices of GPU, hoping that we can buy a GPU at a lower price someday.

In this problem, you need to write a program to track the price of GPU. Initially, there will be an input representing the price of GPU for each day. You need to find the maximum number of consecutive days starting from today and going backward, for which price was larger than or equal to today's price.

 

For example, the prices of GPU for one week are [ 17980, 16500, 18200, 19360, 14050, 15990, 12990 ] , then

- In the first day, since it is the beginning, return 1.

- In the second day, because the price in first day is greater than the current one, so return 2.

- In the third day and the fourth day, because the prices are both rising, so return 1 respectively.

- In the fifth day, the prices of the previous 4 days are higher than the price of this day, so return 5.

and the final output will be [1,2,1,1,5,1,7]

 

Note: 

All STL library are forbidden.​

Remember that each output should be followed by a space, and you need to add a newline in the end.

Input

There will be one line of input, which contains several prices separated by space.

1 <= price <= 100,000

1 <= number of prices <= 10000000

End with an EOF character.

Output

Return the the maximum number of consecutive days for each day ( starting from each day and going backward ), for which price was larger than or equal to the price of each day

Sample Input  Download

Sample Output  Download

Tags




Discuss