Logo
(追記) (追記ここまで)

25809번 - K-gap Subsequence 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB30171460.870%

문제

A subsequence of a given sequence of integers is a subset of the values in the sequence in the same order. A k-gap subsequence of a sequence of integers is a subsequence such that consecutive elements in the subsequence differ by at least k. For example, the sequence

3, 12, 8, 4, 2, 5, 1, 9, 8, 6, 5, 1, 7

has a 4-gap subsequence of 3, 12, 8, 4, 9, 5, 1 and 7 (highlighted in bold above) since

|3 - 12|, |12 - 8|, |8 - 4|, |4 - 9|, |9 - 5|, |5 - 1| and |1 - 7| are all 4 or greater.

Given a sequence and a value of k, determine the length of the longest k-gap subsequence.

입력

The first input line contains two space separated integers: n (1 ≤ n ≤ 300,000), indicating the length of the sequence, and k (1 ≤ k ≤ 109), indicating the value of k for the input case.

The following input line contains n space separated integers. The ith of these integers is ai (1 ≤ ai ≤ 109), the ith value of the input sequence.

출력

Print the length of the longest k-gap subsequence of the input sequence.

제한

예제 입력 1

10 2
1 2 3 2 1 3 1 3 5 6

예제 출력 1

7

예제 입력 2

5 12
3 7 14 20 32

예제 출력 2

3

예제 입력 3

13 4
3 12 8 4 2 5 1 9 8 6 5 1 7

예제 출력 3

8

힌트

출처

University > University of Central Florida > 2021 Local Programming Contest (Final Round) 9번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /