#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve()
{
ll n, x;
cin >> n >> x;
ll a[n + 1];
for (ll i = 1; i <= n; i++) cin >> a[i];
ll dp[n + 1];
a[0] = 0;
dp[0] = 0;
for (ll i = 1; i <= n; i++)
{
dp[i] = -1e18;
for (ll j = i - 1; j >= 0; j--) if (a[j] + (i - j) * x >= a[i]) dp[i] = max(dp[i], dp[j] + 1);
}
cout << n - *max_element(dp, dp + n + 1) << endl;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
ll t = 1;
// precomp();
// cin >> t;
for (ll cs = 1; cs <= t; cs++)
solve();
// cerr << "\nTime elapsed: " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n";
}
# | 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... |