ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

USU Open Personal Contest 2008

About     Problems     Submit solution     Judge status     Standings
Contest is over

C. Elevator

Time limit: 0.5 second
Memory limit: 64 MB
Problem illustration
Petr is at the upper (nth) floor of a skyscraper, and he wants to go down to the first floor. The indicator above the elevator door shows that the elevator is now going down to the first floor and is at the level of the kth floor. Petr understands that if he goes down several flights of stairs and calls for the elevator from there he may get to the first floor faster. Help Petr to determine how many flights of stairs he should go.
The elevator goes up or down one floor in v seconds, and Petr goes down one flight of stairs in u seconds. When the elevator has reached the first floor, it has to remain there for 15 seconds; then it can go up. You may assume that nobody else will call for the elevator. Boarding the elevator takes 5 seconds. All other delays shouldn't be taken into account.


The single input line contains the numbers n, k, u, and v (1 < k < n < 100; 0.1 < v < u < 100).


Output the number of the floor which Petr should descend to. If there are several equivalent variants, output such one in which Petr will go by foot the smaller distance.


50 49 4.8 0.2
Problem Author: Vladimir Yakovlev
Problem Source: IX USU Open Personal Contest (March 1, 2008)
To submit the solution for this problem go to the Problem set: 1602. Elevator