模拟即可

#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int res = 0;
    bool r = false ; 
    for (int i = 2; i <= n; i++)
    {
        int c = abs(a[i] - a[i - 1]);
        if (k < c && c <= 2 * k)
        {
            res++;
            r = true ; 
        }
        else if (c > 2 * k)
        {
            int xs = c / k;
            if(c % k == 0)
            {
               xs = c / k - 1  ;
            }
            res += xs;
            r = true ; 
        }
        if(c == k)
        {
            r = true ; 
        }
    }
    if(!r)
    {
        res++ ; 
    }
    cout << res << endl;
    return 0;
}