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 int long long
#define matsuri pair<int,int>
//const int iris = 1e9+7;
const int iris = 998244353;
using namespace std;
void solve()
{
int n,d;
cin>>n>>d;
vector<int> arr(n+1), dp(n+1, 1);
dp[0]=0;
for(int i=1;i<=n;i++)
cin>>arr[i];
int ans=0;
for(int i=1;i<=n;i++)
{
int o=0;
for(int j=i-1;j>=0;j--)
{
o++;
if(o>d)
break;
if(arr[j]<arr[i])
dp[i]=max(dp[i], dp[j]+1);
if(arr[j]<=arr[i])
o=0;
}
ans=max(ans, dp[i]);
}
cout<<ans<<endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int T=1;
//cin>>T;
while(T--)
solve();
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... |