Winsorizing the Data
Ledbury Water takes a pressure reading every minute, and a failing gauge now and again reports a value far outside anything the pipe could physically hold. The team will not delete those minutes, because the timeline has to stay unbroken — a missing minute causes more trouble downstream than an implausible one. Instead every reading is pulled back inside the plausible range: anything under the floor is recorded as the floor, anything over the ceiling as the ceiling, and anything already inside is left exactly as it is.
Task: Print every reading pulled inside the allowed range.
Input
Three parts. The first line holds the floor followed by the ceiling, separated by a single space. The second line holds one integer n, how many readings follow. Each of the next n lines holds one reading as a plain number, which may be negative. A reading sitting exactly on the floor or exactly on the ceiling is already inside the range.
Output
n lines in the order the readings arrived, each holding that reading after capping, with exactly one digit after the decimal point.
Example:
Input:
10 50
4
5
25
60
50
Output:
10.0
25.0
50.0
50.0
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in