#include <bits/stdc++.h>
#define lop(i,a,b) for(ll i = a; i < b; i++)
#define alop(i,v) for(auto &i: v)
#define in(v) for(auto &i: v) cin >> i;
#define ll long long
#define endl '\n'
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(p, x) memset(p, x, sizeof(p))
using namespace std;
ll mod = 1e9 + 7;
int main(){
ll n, m; cin >> n >> m;
ll arr[n + 1] = {}, dp[n + 1] = {};
lop(i, 0, n) cin >> arr[i + 1];
if(m >= arr[1]) dp[1] = 1;
ll ans = -1;
for(int i = 2; i <= n; i++){
for(int j = 1; j < i; j++){
if(arr[j] + m * (i - j) >= arr[i] && dp[j] > 0) dp[i] = max(dp[i], dp[j] + 1);
}
ans = max(ans, dp[i]);
}
cout << n - ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |