#include <bits/stdc++.h>
using namespace std;
const int nx=5e4+5;
int n, m, a[nx], dp[nx][nx], ans=1e9;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m;
for (int i=1; i<=n; i++) cin>>a[i];
for (int i=1; i<nx; i++) dp[0][i]=nx;
for (int i=1; i<=n; i++)
{
for (int j=0; j<nx; j++) dp[i][j]=dp[i-1][j]+1;
for (int j=max(0, a[i]-m); j<nx; j++) dp[i][a[i]]=min(dp[i][a[i]], dp[i-1][j]);
}
for (int i=0; i<nx; i++) ans=min(ans, dp[n][i]);
cout<<ans;
}
Compilation message
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status