루미 알고리즘

#1290다이아Beetle

PO 2009 BOI 선발코딩영어 원문이 문제가 어렵다면 — 배우는 순서 보기

영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)

Problem

A beetle finds itself on a thin horizontal branch. “Here I am on a thin horizontal branch”, thinks the beetle, “I feel pretty much like on an x-axis!”. It surely is a beetle of deep mathematical thought.

There are also n drops of dew on that same branch, each holding m units of water. Their beetle-based integer coordinates are x_1, x_2, …, x_n.

It is clear that the day will be hot. Already in one unit of time one unit of water goes away from each drop. The beetle is thirsty. It is so thirsty that if it reached a drop of dew it would drink it in zero time. In one unit of time the beetle can crawl one unit of length. But would all this crawling pay off? That's what buzzes the beetle.

So you are to write a program which, given coordinates of dew drops, calculates the maximal amount of water the beetle can possibly drink.

Input

The first line contains two integers n and m (1 ≤ n ≤ 300, 1 ≤ m ≤ 10^6).

The next n lines each contain one of the integer coordinates x_1, x_2, …, x_n (-10,000 ≤ x_i ≤ 10,000). Each x_i is distinct.

Output

Print an integer: the maximum amount of water the beetle can possibly drink.

Scoring

Your solution will be tested on a set of test groups. To earn points for a group, you must pass all test cases in that group.

GroupPointsConstraints
15x_i ≥ 0
210n ≤ 20, m ≤ 1000
335n ≤ 100, m ≤ 1000
430n ≤ 100
520No additional constraints.

예제

예제 1

입력
3 15
6
-3
1
출력
25

출처 표기

출처: Programmeringsolympiaden 2009년 BOI 선발 · 권리자: Baltic Olympiad in Informatics · 원문 페이지 · 이용 조건 CC BY-SA · LaTeX 원문을 화면용 글로 옮겼습니다(수식·표의 모양이 다를 수 있습니다). 내용은 고치지 않았습니다.

크리에이티브 커먼즈 저작자표시-동일조건변경허락.

문제 출처: 한국정보올림피아드(KOI) (CC BY-NC-SA 4.0) · International Olympiad in Informatics (IOI) (CC BY) · Centre for Education in Mathematics and Computing (CEMC), University of Waterloo (CC BY-NC 4.0) · Programmeringsolympiaden (CC BY-SA) · CSES Problem Set (Antti Laaksonen) (CC BY-NC-SA 4.0). 루미 알고리즘은 위 단체들과 관계없는 별도의 서비스이며, 자료는 원문 그대로 싣습니다. 문제마다 출처와 이용 조건을 따로 표기합니다.