AT_abc403_d [ABC403D] Forbidden Difference
Description
You are given a length- $ N $ integer sequence $ A=(A_1,A_2,\dots,A_N) $ and a non-negative integer $ D $ . We wish to delete as few elements as possible from $ A $ to obtain a sequence $ B $ that satisfies the following condition:
- $ |B_i - B_j|\neq D $ for all $ i,j \; (1 \leq i < j \leq |B|) $ .
Find the minimum number of deletions required.
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ D $ $ A_1 $ $ A_2 $ $ \dots $ $ A_N $
Output Format
Print the answer.
Explanation/Hint
### Sample Explanation 1
Deleting $ A_1=3 $ yields $ B=(1,4,1,5) $ , which satisfies $ |B_i - B_j|\neq 2 $ for all $ i