Linear Galaxy
Time limit2sMemory limit512 MB
Given 2^n + 1 points on a line, choose 2^(n-1) + 1 of them so that the minimum gap around their cyclic order is as large as possible.
- Level
Medium7 of 10
- Topics
- Sorting, Greedy, Combinatorics
- Solved
- No attempts yet
Problem
The government of the "Linear" galaxy plans to redesign the public transportation system of the galaxy. The Linear galaxy lies very far from our own galaxy and consists of stars placed on a single line. Taking the origin of the line as the starting point of the galaxy, the -th star sits at position , so the distance between stars and is .
The Linear galaxy has two transportation systems, TRT and SRT.
Teleport Rapid Transit (TRT) is the advanced one. A traveler is teleported instantly from one star of the TRT network to another star of that network. Equipment is limited, so TRT stations can be installed in only stars.
To make the whole transportation network connected, one star of the TRT network together with every star outside the TRT network, stars in total, must be joined by the traditional Spacecraft Rapid Transit (SRT) system. A standard SRT network over stars is a cycle of length that passes through each of those stars exactly once. Spacecrafts work more efficiently on longer flights, so the efficiency of an SRT network is the minimum of its flight distances, that is, the smallest distance between two consecutive stars of the cycle.
The government looks for the SRT network of maximum efficiency built over of the stars. Report that maximum efficiency.
When , the SRT network passes through 2 stars and has a single flight running back and forth between them, so its efficiency is the distance between those 2 stars.
Input
The input holds several test cases. The first line of each test case contains one integer (), and the Linear galaxy then has stars. The next line contains distinct positive integers not exceeding , the positions of the stars. The positions are not necessarily sorted. The input ends with a line containing 0, which must not be processed.
Output
For each test case, print one line with a single integer, the maximum efficiency among all possible SRT/TRT networks.