이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define debug(x) cout<<#x<<": "<<x<<"\n"
signed main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// freopen("input.000","r",stdin);
// freopen("output.000","w",stdout);
// srand((unsigned)time(NULL));
// rand()
int n,a[300005],dp[300005],i,max_dist,c,d,j,ans;
bool reach[7005][7005];
cin>>n>>d;
for (i=1;i<n+1;i++) cin>>a[i];
for (i=1;i<n;i++)
{
max_dist=0;c=0;
reach[i][i+1]=(a[i]<a[i+1]);
for (j=i+1;j<n;j++)
{
if (a[i]<a[j])
{
c++;max_dist=max(max_dist,c);
}
else c=0;
reach[i][j+1]=(max_dist<d and a[i]<a[j+1]);
}
}
dp[1]=1;
for (i=2;i<n+1;i++)
{
dp[i]=1;
for (j=1;j<i;j++) if (reach[j][i]) dp[i]=max(dp[i],dp[j]+1);
}
ans=1;
for (i=2;i<n+1;i++) 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... |