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

7036번 - Grazing on the Run 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB120826872.340%

문제

A long, linear field has N (1 <= N <= 1,000) clumps of grass at unique integer locations on what will be treated as a number line.Think of the clumps as points on the number line.

Bessie starts at some specified integer location L on the number line (1 <= L <= 1,000,000) and traverses the number line in the two possible directions (sometimes reversing her direction) in order to reach and eat all the clumps. She moves at a constant speed (one unit of distance in one unit of time), and eats a clump instantly when she encounters it.

Clumps that aren't eaten for a while get stale. We say the "staleness" of a clump is the amount of time that elapses from when Bessie starts moving until she eats a clump. Bessie wants to minimize the total staleness of all the clumps she eats.

Find the minimum total staleness that Bessie can achieve while eating all the clumps.

입력

  • Line 1 : Two space-separated integers: N and L.
  • Lines 2..N+1: Each line contains a single integer giving the position P of a clump (1 <= P <= 1,000,000).

출력

  • Line 1: A single integer: the minimum total staleness Bessie can achieve while eating all the clumps.

제한

예제 입력 1

4 10
1
9
11
19

예제 출력 1

44

힌트

출처

Olympiad > USA Computing Olympiad > 2005-2006 Season > USACO November 2005 Contest > Gold 2번

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

출처

대학교 대회

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

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