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
const int LINF = (int)1e18;
int n, d, dp[300010], a[300010];
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> d;
for(int i = 0; i < n; i++) cin >> a[i];
fill(dp, dp+n, 1);
set<int> S; S.insert(a[0]);
for(int i = n-2; i >= 0; i--){
for(int j = i+1; j<=min(n-1,i+d); j++){
if(a[j]>a[i]) dp[i] = max(dp[i], dp[j]+1);
}
S.insert(a[i]);
}
//for(int i = 1; i <= n; i++) cout << dp[i-1] << " "; cout << "\n";
cout << *max_element(dp, dp+n);
}
# | 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... |