[Solution] Luke is a foodie Codeforces Solution
Luke likes to eat. There are piles of food aligned in a straight line in front of him. The -th pile contains units of food.
Luke will walk from the -st pile towards the -th pile, and he wants to eat every pile of food without walking back. When Luke reaches the -th pile, he can eat that pile if and only if , where is a fixed integer, and is Luke's food affinity.
Before Luke starts to walk, he can set to any integer. Also, for each (), Luke can change his food affinity to any integer before he eats the -th pile.
Find the minimum number of changes needed to eat every pile of food.
- of
Note that the initial choice for is not considered as a change.
The input consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of test cases follows.
For each test case, the first line contains two integers, (, ) — 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 integers ().
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, output an integer on a separate line, which is the minimum number of changes needed.
No comments:
Post a Comment