This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
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... |