## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Luke is a foodie Codeforces Solution

B. Luke is a foodie
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Luke likes to eat. There are $n$ piles of food aligned in a straight line in front of him. The $i$-th pile contains ${a}_{i}$ units of food.

Luke will walk from the $1$-st pile towards the $n$-th pile, and he wants to eat every pile of food without walking back. When Luke reaches the $i$-th pile, he can eat that pile if and only if $|v-{a}_{i}|\le x$, where $x$ is a fixed integer, and $v$ is Luke's food affinity.

Before Luke starts to walk, he can set $v$ to any integer. Also, for each $i$ ($1\le i\le n$), Luke can change his food affinity to any integer before he eats the $i$-th pile.

Find the minimum number of changes needed to eat every pile of food.

• of
Solution Click Below:-  👉

👇👇👇👇👇

Note that the initial choice for $v$ is not considered as a change.

Input

The input consists of multiple test cases. The first line contains a single integer $t$ ($1\le t\le {10}^{4}$) — the number of test cases. The description of test cases follows.

For each test case, the first line contains two integers, $n,x$ ($1\le n\le 2\cdot {10}^{5}$$1\le x\le {10}^{9}$) — the number of piles, and the maximum difference between the size of a pile and Luke's food affinity, such that Luke can eat the pile.

The second line contains $n$ integers ${a}_{1},{a}_{2},\dots ,{a}_{n}$ ($1\le {a}_{i}\le {10}^{9}$).

It is guaranteed that the sum of $n$ over all test cases does not exceed $2\cdot {10}^{5}$.

Output

For each test case, output an integer on a separate line, which is the minimum number of changes needed.