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 <iostream>
#include <vector>
using namespace std;
const int N = 7005;
int n, d, a[N], dp[N], ans = 0;
signed main()
{
cin >> n >> d;
for (int i = 0; i < n; i++)
cin >> a[i];
dp[n - 1] = 1;
for (int i = n - 2; i >= 0; i--) {
dp[i] = 1;
int k = i;
for (int j = i + 1; j < n; j++) {
if (j - k > d)
break;
if (a[j] <= a[i])
k = j;
else
dp[i] = max(dp[i], dp[j] + 1);
}
ans = max(ans, dp[i]);
}
cout << ans;
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |