#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=3e5+5;
int dp[N];
int a[N];
signed main(){
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++)cin>>a[i];
int ans=0;
dp[0]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<i;j++){
if(a[i]-a[j]>=k)continue;
dp[i]=max(dp[i],dp[j]+1);
}
ans=max(ans,dp[i]);
}
cout<<n-ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |