Similar Spacing

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

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 aa is the maximum distance between any two adjacent restaurants and bb is the minimum distance between any two adjacent restaurants, place your restaurants such that aba-b is minimized.

입력

The first line of input contains two integers NN and KK (with 2N1002≤N≤100 and 2KN2≤K≤N) where NN is the number of potential restaurant sites, and KK is the number of restaurants to build. The second line of input contains N1N-1 integers d_1,,d_N1d\_1,\dots ,d\_{N-1} (with 0d_i<2310≤d\_i<2^{31}) where d_id\_i is the distance between restaurant site ii and i+1i+1.

출력

Display the number aba-b.

힌트

In Sample Input 2, an optimal solution could place restaurants at sites 113355, and 66. With this placement the distances between adjacent restaurants are d_1+d_2d\_1+d\_2d_3+d_4d\_3+d\_4, and d_5d\_5, respectively. So, a=10a=10 (the maximum of these), b=8b=8 (the minimum), and ab=2a-b=2.

In Sample Input 3, an optimal solution could place restaurants at sites 33446677, and 88. With this placement the distances between adjacent restaurants are d_3d\_3d_4+d_5d\_4+d\_5d_6d\_6, and d_7d\_7, respectively. So, a=32a=32b=18b=18, and ab=14a-b=14.