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 <iostream>
using namespace std;
const int N = 7005;
int n, d, a[N], dp[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> d;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int ans = 0;
for (int i = 0; i < n; i++) {
dp[i] = 1;
int x = i;
for (int j = i - 1; j >= max(0, x - d); j--) {
if (a[j] >= a[i]) continue;
x = j;
dp[i] = max(dp[i], 1 + dp[j]);
}
ans = max(ans, dp[i]);
}
cout << ans << '\n';
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... |