

Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 150 点
問題文
高橋村の長老はすぐに寝てしまいます。具体的には、最後に肩を叩かれてから S+0.5 秒以上経過すると長老は寝てしまいます。
現在、長老は起きており、付き人がちょうど長老の肩を叩きました。
これから付き人はちょうど N 回長老の肩を叩きます。i 回目の肩叩きは現在から T_i 秒後に行われます。
長老が現在から T_N 秒後まで連続して起きているかを判定してください。
制約
- 1 \leq N \leq 100
- 1 \leq S \leq 100
- 1 \leq T_i \leq 1000 (1 \leq i \leq N)
- T_i < T_{i+1} (1 \leq i \leq N-1)
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N S T_1 T_2 \ldots T_N
出力
長老が現在から T_N 秒後まで連続して起きているならば Yes
を、そうでないならば No
を出力せよ。
入力例 1
5 10 6 11 21 22 30
出力例 1
Yes
付き人は時系列順に以下のように肩を叩きます。
- 6 秒後に肩を叩きます。このとき、長老は最後に肩を叩かれてから 6 秒しか経過していないので起きています。
- 11 秒後に肩を叩きます。このとき、長老は最後に肩を叩かれてから 5 秒しか経過していないので起きています。
- 21 秒後に肩を叩きます。このとき、長老は最後に肩を叩かれてから 10 秒しか経過していないので起きています。
- 22 秒後に肩を叩きます。このとき、長老は最後に肩を叩かれてから 1 秒しか経過していないので起きています。
- 30 秒後に肩を叩きます。このとき、長老は最後に肩を叩かれてから 8 秒しか経過していないので起きています。
現在から 30 秒後まで長老は起きているので、Yes
と出力します。
入力例 2
2 100 1 200
出力例 2
No
長老は現在から 101.5 秒後に寝てしまいます。そのため No
と出力します。
入力例 3
10 22 47 81 82 95 117 146 165 209 212 215
出力例 3
No
Score : 150 points
Problem Statement
The elder of Takahashi Village falls asleep immediately. Specifically, if S+0.5 seconds or more have passed since the elder was last tapped on the shoulder, the elder falls asleep.
Currently, the elder is awake, and an attendant has just tapped the elder on the shoulder.
From now on, the attendant will tap the elder's shoulder exactly N times. The i-th shoulder tap will be performed T_i seconds from now.
Determine whether the elder remains awake continuously from now until T_N seconds later.
Constraints
- 1 \leq N \leq 100
- 1 \leq S \leq 100
- 1 \leq T_i \leq 1000 (1 \leq i \leq N)
- T_i < T_{i+1} (1 \leq i \leq N-1)
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N S T_1 T_2 \ldots T_N
Output
If the elder remains awake continuously from now until T_N seconds later, output Yes
; otherwise, output No
.
Sample Input 1
5 10 6 11 21 22 30
Sample Output 1
Yes
The attendant taps the shoulder in chronological order as follows:
- Taps after 6 seconds. At this time, only 6 seconds have passed since the elder was last tapped on the shoulder, so the elder is awake.
- Taps after 11 seconds. At this time, only 5 seconds have passed since the elder was last tapped on the shoulder, so the elder is awake.
- Taps after 21 seconds. At this time, only 10 seconds have passed since the elder was last tapped on the shoulder, so the elder is awake.
- Taps after 22 seconds. At this time, only 1 second has passed since the elder was last tapped on the shoulder, so the elder is awake.
- Taps after 30 seconds. At this time, only 8 seconds have passed since the elder was last tapped on the shoulder, so the elder is awake.
Since the elder is awake from now until 30 seconds later, output Yes
.
Sample Input 2
2 100 1 200
Sample Output 2
No
The elder falls asleep 101.5 seconds from now. Therefore, output No
.
Sample Input 3
10 22 47 81 82 95 117 146 165 209 212 215
Sample Output 3
No