Digital Speedometer
题号:NC225362
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

    A digital speedometer shows a vehicle’s speed as integer miles per hour. There are occasions when the sensed speed varies between two integer values, such as during cruise control. Using a single threshold to round between adjacent integers often makes the display toggle rapidly between the two integers, which is distracting to the driver.
    Your team must implement a smoothing technique for the display using separate rising and falling thresholds ( and  , , respectively). See Figure  for a graphical depiction of the Sample Input for use with the following rules. 
    Each sensed speed, , falls between two adjacent integers  and , , where . When displaying the sensed speed as an integer: 
  • When  falls between  and , is displayed as .
  • When falls between  and , is displayed as .
  • When falls between and , is displayed as if the most recent preceding value for outside of range  is less than , and is displayed as if the most recent preceding value for outside of range [i + tf , i + tr] is greater than
  •  Any sensed speed, , must display as  because any non-zero speed, no matter how small, must display as non-zero to indicate that the vehicle is in motion. 

输入描述:

The first line of input contains , the falling threshold. The second line of input contains , the rising threshold. Thespeed sensor reports in increments of  mph. The thresholds are always set halfway between speed increments.All remaining lines until end-of-file are successive decimal speeds, , in miles per hour, one speed per line. The thirdline of input, which is the first measured speed, will always be . There are at most  observed speeds in input. 

输出描述:

Output is the list of speeds, one speed per line, smoothed to integer values appropriate to  and .
示例1

输入

复制
0.25
0.75
0
2.0
5.7
5.8
5.7
5.2
5.7
0.8
0.2

输出

复制
0
2
5
6
6
5
5
1
1

说明