#P6281. [USACO20OPEN] Social Distancing S
[USACO20OPEN] Social Distancing S
Description
Due to the outbreak of the highly contagious cow disease COWVID-19, Farmer John is very worried about the health of his cows.
To limit the spread of the disease, Farmer John’s cows () decide to practice “social distancing” and spread out across the farm. The farm can be seen as a one-dimensional number line with disjoint intervals () that contain grass available for grazing. The cows want to stand at different integer positions, where each chosen position has grass, and maximize the value of , where is the distance between the closest two cows. Please help the cows find the maximum possible value of .
Input Format
The first line contains and . The following lines each contain two integers and describing an interval, where . No two intervals overlap or touch at endpoints. A cow standing on an endpoint of an interval is considered to be standing on grass.
Output Format
Output the maximum possible value of such that the distance between every pair of cows is at least . It is guaranteed that a solution with exists.
5 3
0 2
4 7
9 9
2
Hint
Sample Explanation
One way to achieve is to place the cows at positions , , , , and .
Subtasks
- Test cases - satisfy .
- Test cases - have no additional constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号