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 main()
{
int n, d, i, j, k, m = 0;
cin >> n >> d;
vector<int> v(n);
vector<vector<int> > dp(n);
for (i = 0; i < n; i++)
{
cin >> v[i];
dp[i].resize(i + 1);
for (j = 0; j <= i; j++)
{
dp[i][j] = 0;
if (j)
{
dp[i][j] = 1000000001;
for (k = i - 1; k >= 0 && k >= i - d; k--)
{
if (j - 1 <= k && dp[k][j - 1] < v[i])
dp[i][j] = min(dp[i][j], dp[k][j - 1]);
else if (j <= k)
dp[i][j] = min(dp[i][j], dp[k][j]);
}
}
dp[i][j] = max(dp[i][j], v[i]);
if (i == n - 1 && dp[i][j] < 1000000001)
m = j;
}
}
cout << m + 1;
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... |