#P2855. [USACO06DEC] River Hopscotch S
[USACO06DEC] River Hopscotch S
Description
Every year the cows hold a peculiar hopscotch event, carefully jumping from one rock to another in a river. The competition is on a long straight river with a rock at the start and another rock at the end, which is units away from the start (). Between the start and end rocks, there are additional rocks (), each at an integer distance from the start ().
During the game, each cow starts from the start rock and tries to reach the end rock, only allowed to jump from one rock to another. Of course, the less agile cows will never reach the end rock and will eventually fall into the river.
Farmer John is proud of his cows and watches this contest every year. Over time, however, he has grown tired of watching timid cows from other farms hobble across short gaps between rocks. He plans to remove some rocks to increase the minimal distance the cows must jump to reach the end. He knows he cannot remove the start and end rocks, but he has enough resources to remove at most rocks ().
Before he starts removing rocks, FJ wants to know how much he can increase the minimal jump distance. Please determine, after optimally removing at most rocks, the maximum possible minimal distance that any cow must jump.
Formal statement: Given points on a line, remove at most points so that the minimum distance between consecutive remaining points (including the start at and the end at ) is maximized.
Input Format
The first line contains three space-separated integers: , , and .
Lines each contain one integer, the distance of a rock from the start. No two rocks share the same position.
Output Format
Output a single integer, the maximum possible value of the minimal jump distance after removing at most rocks.
25 5 2
2
14
11
21
17
4
Hint
Before removing any rock, the shortest jump is a length- jump from (start) to ; after removing the rocks at and , the required shortest jump is (from to or from to ).
Translated by ChatGPT 5
京公网安备 11011102002149号