Problem E
Charles in Charge
Every day, Charles drives from his home to work and back. He uses the highways of the country that run from one city to another. Charles has decided that he wants to help the environment by buying an electrical car. Electrical cars, however, are not very common in his country yet. They can only be charged inside a city; there are no charging stations along the highways in between the cities. Moreover, all electrical cars are identical except for one thing: the size of the battery. As batteries are very expensive, Charles would like to buy a car with battery that is as small as possible.
However, this greatly increases the time it takes for him to
get home, much to the distaste of his wife, Charlotte. This has
spawned an argument, and after much discussion they have
decided to compromise: Charlotte is fine with Charles taking a
longer route, as long as it its length is at most
The amount of time Charles spends to charge his car can be neglected.
![\includegraphics[width=0.5\textwidth ]{testcase.pdf}](/problems/charlesincharge/file/statement/en/img-0002.png)
Input
The input starts with integers
Then follow
Output
The output is a single integer: the smallest maximum
distance that Charles has to travel on a highway without
passing through a city, such that the route he takes is at most
Sample Input 1 | Sample Output 1 |
---|---|
2 1 100 1 2 5 |
5 |
Sample Input 2 | Sample Output 2 |
---|---|
9 8 15 1 9 16 1 4 4 4 5 4 5 6 4 6 8 4 4 7 5 7 8 5 8 9 4 |
5 |
Sample Input 3 | Sample Output 3 |
---|---|
9 8 30 1 9 16 1 4 4 4 5 4 5 6 4 6 8 4 4 7 5 7 8 5 8 9 4 |
4 |