#include<bits/stdc++.h>
#include<string.h>
#include <algorithm>
#include <stdlib.h>
#define ll long long
using namespace std;
ll k[300006],a,b,c,d,e,f,m[300006],i,j,n,h,g,l,r,ka,p,q[200005],t[200005];
map<ll,ll> maa,mii,mee;
vector<ll> vas[25],vis,vii;
int main(){
cin>>a>>b;
for(i=0 ; i<a ; i++){
cin>>k[i];
}
t[0]=1;
for(i=1 ; i<a ; i++){
h=0;
g=i;
for(j=i-1 ; j>=0 ; j--){
if(k[j]<k[i]){
if(g-j<=b){
g=j;
}
else{
j=g;
break;
}
}
if(g-j>b){
j=g;
break;
}
}
if(j==-1){
j=0;
}
for(j=j ; j<i ; j++){
if(k[j]<k[i]){
h=max(h,t[j]);
}
}
t[i]=h+1;
}
h=0;
for(i=a-1 ; i>=0 ; i--){
h=max(h,t[i]);
}
cout<<h;
}
# | 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... |