Problem D
Climbing Stairs
Your workplace recently announced a staircase cup with some fabulous prizes to win. The rules of participation are simple: Each day, it is possible to gain one point, and at the end of the month, whoever has the most points wins. In order to get a point for a specific day, you need to first walk $n$ steps (either upwards or downwards) in the staircase — thereafter you must register your achievement in the registration book at the registration desk.
While you would like to participate in the cup (the prizes are quite nice) you also don’t like walking on stairs that much, and would like to know the minimal number of steps you need to walk each day in order to get a point. You also plan to spend most of your day in your office, and you will enter and leave the building through the only entrance on the ground floor. There are no elevators and no underground floors in the building.
Input
One line with three numbers $n$ ($1 \leq n \leq 1\, 000$), $r$ ($0 \leq r \leq 1\, 000$) and $k$ ($0 \leq k \leq 1\, 000$), respectively indicating the number of steps required before you can register, the number of steps from the ground floor to the registration desk, and the number of steps from the ground floor to the floor of your office.
Output
The minimal number of staircase steps needed to participate in the staircase cup each day.
Sample Input 1 | Sample Output 1 |
---|---|
20 10 5 |
30 |