Hide and Seek 6
InterviewTime limit1sMemory limit512 MB
Given Subin's position S and the positions of N siblings, find the largest step size D such that repeated moves of +D or -D from S can reach every sibling.
- Level
Medium4 of 10
- Topics
- Math, Number theory, Greedy, Implementation
- Solved
- No attempts yet
Problem
Subin is playing hide and seek with N younger siblings. Subin is currently at point S, and the siblings are at A1, A2, ..., AN.
Subin can move by walking. When Subin is at position X, walking moves her to X+D or X-D after 1 second. If Subin's position equals the position of a sibling, she has found that sibling.
She wants to choose the value of D so that she can find all the siblings. Find the maximum possible value of D.
Input
The first line gives N (1 ≤ N ≤ 105) and S (1 ≤ S ≤ 109). The second line gives the positions of the siblings Ai (1 ≤ Ai ≤ 109). All sibling positions are distinct and none equals Subin's position.
Output
Print the maximum possible value of D.