Logo
(追記) (追記ここまで)

26991번 - Finicky Grazers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB59151135.484%

문제

Farmer John's N (1 ≤ N ≤ 10,000) cows (conveniently numbered 1..N) graze in a straight line in their pasture whose length is L+1 (N ≤ L ≤ 100,000) meters. Every morning, they place themselves at various unique integer locations along that line. FJ has observed that the cows produce more milk when the distance to the other grazing cows is maximized.

Always the enterprising farmer, FJ wants to maximize the distance between each and every pair of neighboring cows by moving the cows to the right or left, but always with integer inter-cow spacing and never changing their order on the line. He spends 1 minute to move a cow 1 meter. When he's finished, he knows that the distances between every adjacent pair of cows will be one of two integers: D or D+1.

Help FJ to calculate minimum time he needs to arrange the positions of the cows.

입력

  • Line 1: Two space-separated integers, N and L
  • Lines 2..N+1: Line i+1 describes cow i with a single integer (range 0..L) representing the position of a cow; 0 is the left-most position. The list is sorted by position with the smallest position value first.

출력

  • Line 1: A single line with minimum time FJ needs to arrange the positions of the cows.

제한

예제 입력 1

5 10
0
1
4
9
10

예제 출력 1

3

힌트

출처

Olympiad > USA Computing Olympiad > 2005-2006 Season > USACO January 2006 Contest > Bronze ?번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /