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;
int dp[300005], A[300005];
int main(){
int n,d;
cin >> n >> d;
for(int i=1;i<=n;i++)cin >> A[i];
for(int i=1;i<=n;i++){
vector<int>v;
for(int j=i-1;j>=1;j--)if(A[j] < A[i])v.push_back(j);
int prev = i;
for(auto j : v){
if(prev - j > d)break;
dp[i] = max(dp[i], dp[j]);
prev = j;
}
dp[i]++;
}
int ans =0 ;
for(int i=1;i<n;i++)ans = max(ans, dp[i]);
cout << max(ans, 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... |