CF1650E.Rescheduling the Exam

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Now Dmitry has a session, and he has to pass nn exams. The session starts on day 11 and lasts dd days. The ii th exam will take place on the day of aia_i ( 1aid1 \le a_i \le d ), all aia_i — are different.

Sample, where n=3n=3 , d=12d=12 , a=[3,5,9]a=[3,5,9] . Orange — exam days. Before the first exam Dmitry will rest 22 days, before the second he will rest 11 day and before the third he will rest 33 days.For the session schedule, Dmitry considers a special value μ\mu — the smallest of the rest times before the exam for all exams. For example, for the image above, μ=1\mu=1 . In other words, for the schedule, he counts exactly nn numbers — how many days he rests between the exam i1i-1 and ii (for i=0i=0 between the start of the session and the exam ii ). Then it finds μ\mu — the minimum among these nn numbers.

Dmitry believes that he can improve the schedule of the session. He may ask to change the date of one exam (change one arbitrary value of aia_i ). Help him change the date so that all aia_i remain different, and the value of μ\mu is as large as possible.

For example, for the schedule above, it is most advantageous for Dmitry to move the second exam to the very end of the session. The new schedule will take the form:

Now the rest periods before exams are equal to [2,2,5][2,2,5] . So, μ=2\mu=2 .Dmitry can leave the proposed schedule unchanged (if there is no way to move one exam so that it will lead to an improvement in the situation).

输入格式

The first line of input data contains an integer tt ( 1t1041 \le t \le 10^4 ) — the number of input test cases. The descriptions of test cases follow.

An empty line is written in the test before each case.

The first line of each test case contains two integers nn and dd ( 2n2105,1d1092 \le n \le 2 \cdot 10^5, 1 \le d \le 10^9 ) — the number of exams and the length of the session, respectively.

The second line of each test case contains nn integers aia_i ( 1aid,ai<ai+11 \le a_i \le d, a_i < a_{i+1} ), where the ii -th number means the date of the ii -th exam.

It is guaranteed that the sum of nn for all test cases does not exceed 21052 \cdot 10^5 .

输出格式

For each test case, output the maximum possible value of μ\mu if Dmitry can move any one exam to an arbitrary day. All values of aia_i should remain distinct.

输入输出样例

  • 输入#1

    9
    
    3 12
    3 5 9
    
    2 5
    1 5
    
    2 100
    1 2
    
    5 15
    3 6 9 12 15
    
    3 1000000000
    1 400000000 500000000
    
    2 10
    3 4
    
    2 2
    1 2
    
    4 15
    6 11 12 13
    
    2 20
    17 20

    输出#1

    2
    1
    1
    2
    99999999
    3
    0
    1
    9

说明/提示

The first sample is parsed in statement.

One of the optimal schedule changes for the second sample:

Initial schedule.

New schedule.

In the third sample, we need to move the exam from day 11 to any day from 44 to 100100 .

In the fourth sample, any change in the schedule will only reduce μ\mu , so the schedule should be left as it is.

In the fifth sample, we need to move the exam from day 11 to any day from 100000000100000000 to 300000000300000000 .

One of the optimal schedule changes for the sixth sample:

Initial schedule.

New schedule.

In the seventh sample, every day is exam day, and it is impossible to rearrange the schedule.

首页