This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n , d;
int a[N];
int dp[N];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> d;
for (int i = 1 ; i <= n ; ++i) cin >> a[i];
for (int i = 1 ; i <= n ; ++i)
{
dp[i] = 1;
for (int j = i - 1 ; j >= max(i - d , 1) ; --j)
{
if (a[i] > a[j]) dp[i] = max(dp[i] , dp[j] + 1);
}
}
int ans = 0;
for (int i = 1 ; i <= n ; ++i) ans = max(ans , dp[i]);
cout << ans;
}
# | 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... |