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 n, d, dp[300010], a[300010];
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> d;
for(int i = 0; i < n; i++) cin >> a[i];
reverse(a, a+n); dp[0] = 1;
for(int i = 1; i < n; i++)
for(int j = i-1; j>=max(0,i-d); j--)
dp[i] = max(dp[i], a[j]>a[i]?dp[j]+1:1);
cout << *max_element(dp, dp+n);
}
# | 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... |