문제
After the last debacle involving Farmer John's circular barn, one would think he had learned his lesson about non-traditional architecture. However, he thinks he can still make his circular barn (from the preceding problem) function properly by allowing multiple cows into each room. To recap, the barn consists of a ring of
Farmer John wants exactly
Problem credits: Brian Dean
입력
The first line of input contains
출력
Please write out the minimum amount of distance the cows need to travel.
예제
6 2
2
5
4
2
6
2
14
Farmer John can unlock doors 2 and 5. 11 cows enter at door 2 and walk a total distance of 8 to get to rooms 2, 3, and 4. 10 cows enter at door 5 and walk a total distance of 6 to get to rooms 5, 6 and 1.