PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CT0000060. Dãy bền vững (Stable Sequence)

Bài tập này chưa được xếp vào lộ trình.

Dãy bền vững (Stable Sequence)

Stable Sequence

Version: Phuoc Hung OJ Extended

Problem Statement

Given an integer sequence A1,A2,…,ANA_1,A_2,\ldots,A_N and an integer DD. You may delete some elements while preserving the relative order of the remaining elements.

Suppose the kept positions are

i1<i2<⋯<im.i_1<i_2<\cdots<i_m.

The remaining sequence is stable if for every 1≤t<m1\le t<m,

Ait+1−Ait≥D(it+1−it).A_{i_{t+1}}-A_{i_t}\ge D(i_{t+1}-i_t).

A one-element sequence is always stable. Find the minimum number of deletions.

Input

The first line contains N,DN,D.

The second line contains A1,A2,…,ANA_1,A_2,\ldots,A_N.

Output

Print the minimum number of elements that must be deleted.

Subtasks

  • Subtask 1 (30%): N≤2000N\le2000.
  • Subtask 2 (20%): D=0D=0.
  • Subtask 3 (50%): 1≤N≤2⋅1051\le N\le2\cdot10^5, ∣D∣≤109|D|\le10^9, ∣Ai∣≤109|A_i|\le10^9.

Examples

Example 1

Input

6 2
3 5 6 10 11 15

Output

2

Explanation

Keep positions 1,2,4,61,2,4,6 to obtain 3,5,10,153,5,10,15. It is impossible to delete only one element.

Example 2

Input

5 0
4 1 2 2 5

Output

1

Explanation

Delete the first element; 1,2,2,51,2,2,5 is nondecreasing, exactly the condition for D=0D=0.

Example 3

Input

4 -1
5 3 2 0

Output

2

Explanation

Positions 2,32,3 can be kept because 2−3=−1≥−1⋅(3−2)2-3=-1\ge-1\cdot(3-2). No three positions can be kept.