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 pb push_back
#define int long long
using namespace std;
const int mod = 998244353;
const int inf = 1e9 + 20;
const int N = 1e5+5;
int32_t main(){
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
int n, d;
cin>>n>>d;
vector<int> a(n);
for(int i = 0; i < n; i++){
cin>>a[i];
}
vector<int> dp(n, 1);
int ans = 0;
for(int i = 0; i < n; i++){
int nxt = min(n-1, i + d);
for(int j = i+1; j <= nxt; j++){
if(a[j] <= a[i]) nxt = min(n-1, j+d);
}
for(int j = i+1; j <= nxt; j++){
if(a[j] > a[i]) dp[j] = max(dp[j], dp[i] + 1);
if(a[j] == a[i]) dp[j] = max(dp[j], dp[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... |