问题1312--Double Click

1312: Double Click

[命题人 : ]
时间限制 : 1.000 sec  内存限制 : 128 MB

提交

题目描述

YiDe Zhang turned on a computer at time 0 and click mouse N times. The i-th (1 <= i <= N) click was at time Ti.
If he consecutively clicked the mouse at time x1 and time x2 (where x1<x2), a double click is said to be fired at time x2 if and only if x2x1D.

What time was a double click fired for the first time? If no double click was fired, print -1 instead.

输入

The first line of input includes two integers N and D.
The following line includes N integers.

输出

If at least one double click was fired, print the time of the first such event; otherwise, print -1.

样例输入 Copy

4 500
300 900 1300 1700

样例输出 Copy

1300

提示

  • 1N100
  • 1D109
  • 1Ti109(1iN)
  • Ti<Ti+1(1iN1)
  • All values in the input are integers.

来源/分类