#include <bits/stdc++.h>
using namespace std;
int dp[200005], A[200005];
int main(){
int n,m, maxi =0 ;cin >> n >> m;
for(int i=1;i<=n;i++)cin >> A[i];
for(int i=1;i<=n;i++){
if(A[i] > m * i)dp[i] = -1e9;
else {
for(int j=0;j<=i;j++)if(A[i] - m <= A[j])dp[i] = max(dp[i], dp[j] + 1);
}
maxi = max(maxi, dp[i]);
}
cout << n-maxi;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |