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 mod 1000000007LL
#define inf 1e17
#define ll long long
using namespace std;
void printvec(vector<ll> vec) {
for (auto &&e : vec) {
cout << e << ' ';
}
cout << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n, d;
cin >> n>> d;
vector<ll> a(n);
for(int i=0; i < n; i++) cin >> a[i];
vector<ll> dp(n,1);
dp.back() = 1;
for (int i = n-2; i >= 0; i--)
{
ll cur = 0;
for (int j=i+1; j < n; j++)
{
if(a[j] > a[i])
{
cur++;
dp[i] = max(dp[i], 1 + dp[j]);
if(cur == d)break;
}
else cur = 0;
}
}
cout << *max_element(dp.begin(), dp.end()) << endl;
}
# | 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... |