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;
const int nx=3e5+5;
int n, d, v[nx], l[nx], dp[nx], ans;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>d;
for (int i=1; i<=n; i++)
{
cin>>v[i];
dp[i]=1;
l[i]=i;
for (int j=1; j<i; j++)
{
if (i-l[j]>d) continue;
if (v[j]<v[i]) dp[i]=max(dp[i], dp[j]+1);
else l[j]=i;
}
}
for (int i=1; i<=n; i++) if (l[i]==n) ans=max(ans, dp[i]);
cout<<ans;
}
# | 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... |