PivotOJ

Room Temperature

시간 제한: 2000ms메모리 제한: 1024MB출처: JOI 2023-2024 본선BOJ 31623

문제

President K is taking on the role of adjusting the room temperature of the officers’ room. He wants to make the officers as comfortable as possible.

Now there are NN officers in the room. Each officer is numbered from 11 to NN, and the appropriate temperature for officers ii (1 ≤ i ≤ N) is AiA_i degrees when (s)he is not wearing jackets. For each officer, the appropriate temperature drops by TT degrees every time (s)he wears a jacket. In other words, when the officer ii is wearing kk jackets, her/his appropriate temperature is A_i − kT degrees.

When the room temperature is xx degrees and the appropriate temperature of a certain officer is yy degrees, the discomfort index of the officer is expressed as |x − y|. Note that t|t| represents the absolute value of tt. Each officer wears the appropriate number of jackets of 00 or more to minimize discomfort index, depending on the room temperature.

Here, president K decided to call the maximum discomfort index among all officers as room’s unpleasantness, and set the room temperature so that the room’s unpleasantness was minimized. Note that the room temperature must be an integer.

Write a program which, given information about the officers and the appropriate temperature, calculates the minimum room’s unpleasantness.

입력

Read the following data from the standard input.

NN TT

A1A_1 A2A_2 \cdots ANA_N

출력

Write one line to the standard output. The output should contain the minimum room’s unpleasantness.

예제

예제 1

입력
2 4
19 24
출력
1

예제 2

입력
3 1
21 19 23
출력
0

예제 3

입력
6 8
24 22 21 25 29 17
출력
2
코드를 제출하려면 로그인하세요.