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 fastio ios_base :: sync_with_stdio(0), cin.tie(0);
using namespace std;
using ll = long long;
const int mxN = 1e6 + 5, mod = 1e9 + 7;
int n, d, a[mxN], dp[mxN];
int main() {
fastio;
cin >> n >> d;
for (int i = 1; i <= n; ++i)
cin >> a[i], dp[i] = 1;
int ans = 0;
for (int i = 1; i <= n; ++i) {
int l = i;
for (int j = i + 1; j <= n; ++j) {
if (a[j] <= a[i] && j - l <= d)
l = j;
if (a[j] > a[i] && j - l <= d)
dp[j] = max(dp[j], dp[i] + 1);
}
if (n - l <= d)
ans = max(ans, dp[i]);
}
cout << ans;
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... |