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>
#define MAX (int)(1e6 + 5)
#define ll long long
#define esq(x) (x<<1)
#define dir(x) ((x<<1)|1)
using namespace std;
int n, k, h[MAX], dp[MAX], resp;
int main()
{
cin >> n >> k;
for (int i = 1; i <= n; i++)
{
cin >> h[i];
dp[i] = 1;
}
for (int i = 1; i <= n; i++)
{
for (int j = max(1, i-k); j < i; j++)
{
if (h[j]<h[i]) dp[i] = max(dp[i], dp[j]+1);
}
resp = max(resp, dp[i]);
}
cout << resp << endl;
}
# | 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... |