#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(nullptr); cout.tie(nullptr);
int n, m;
cin >> n >> m;
vector<int> dp(n + 5, 0), ar(n + 5, 0);
for(int i = 1; i <= n; ++i) cin >> ar[i];
int ans = n;
for(int i = 1; i <= n; ++i){
if(ar[i] <= m) dp[i] = 1;
for(int j = i - 1; j >= 1; --j){
if(ar[i] <= ar[j] + m) dp[i] = max(dp[i], dp[j] + 1);
}
if(dp[i] == 0) ar[i] = m;
ans = min(ans, n - dp[i]);
}
cout << ans << "\n";
return 0;
}
| # | 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... |