#K47522. Minimum Required Lamp Power

    ID: 28217 Type: Default 1000ms 256MiB

Minimum Required Lamp Power

Minimum Required Lamp Power

There is a row of houses with given coordinates. Each house is equipped with a lamp that, when set to a power level \(P\), illuminates from \(x - P\) to \(x + P\), where \(x\) is the coordinate of the house. The goal is to determine the minimum required power \(P\) such that the entire segment from the leftmost house to the rightmost house is fully covered by the illumination from the lamps. Note that the provided lamp powers in the input are not used in the calculation.

The answer is computed by finding the maximum gap between consecutive houses and then taking the ceiling of half of that gap. In mathematical terms, if \(G\) is the maximum gap, then the minimum required power is \(P = \lceil \frac{G}{2} \rceil\).

inputFormat

The first line contains an integer (n) representing the number of houses.\nThe second line contains (n) space-separated integers representing the coordinates of the houses.\nThe third line contains (n) space-separated integers representing the lamp powers (this array is provided for compatibility but is not used in the calculation).

outputFormat

Output a single integer which is the minimum required power (P) such that the lamps can collectively illuminate the entire segment from the smallest to the largest house coordinate.## sample

3
1 2 3
1 1 1
1