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;
#define int long long
#define all(x) x.begin(),x.end()
const int INF=1e18;
const int mod=1e9+7;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,k;cin>>n>>k;
vector<int> v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
vector<int> dp(n);
vector<bool> vis(n,1);
vector<int> cnt(n);
for(int i=0;i<n;i++){
dp[i]=1;
for(int j=0;j<i;j++){
if(vis[j]==0){
continue;
}
if(v[i]>v[j]){
dp[i]=max(dp[i],dp[j]+1);
}
}
for(int j=0;j<=i;j++){
if(v[j]>=v[i]){
cnt[j]=0;
}
else{
cnt[j]++;
}
if(cnt[j]>=k){
vis[j]=0;
}
}
}
int ans=0;
for(int i=0;i<n;i++){
ans=max(ans,dp[i]);
}
cout<<ans<<endl;
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... |