Similar Spacing
시간 제한2초메모리 제한1024 MB
직선 위 N개 지점 중 K개를 골라 인접한 선택 지점 사이 간격의 최댓값과 최솟값의 차이를 최소로 만든다.
문제
Finally, your dream of owning a restaurant chain has come true! You have consulted a marketing firm and received instructions on how to best place your restaurants in the city.
The firm has identified potential restaurant sites along a single road, each of which can house a single restaurant. To maximize influencer media impact, you have been advised to build some restaurants along this road and open them all at the same time. Apparently, the best way to attract customers to your chain is to build all of your restaurants with similar spacing along the road; such placement maximizes pedestrian recall coherence, which is all the rage in marketing.
Specifically, if is the maximum distance between any two adjacent restaurants and is the minimum distance between any two adjacent restaurants, place your restaurants such that is minimized.
입력
The first line of input contains two integers and (with and ) where is the number of potential restaurant sites, and is the number of restaurants to build. The second line of input contains integers (with ) where is the distance between restaurant site and .
출력
Display the number .
힌트
In Sample Input 2, an optimal solution could place restaurants at sites , , , and . With this placement the distances between adjacent restaurants are , , and , respectively. So, (the maximum of these), (the minimum), and .
In Sample Input 3, an optimal solution could place restaurants at sites , , , , and . With this placement the distances between adjacent restaurants are , , , and , respectively. So, , , and .