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 ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;
const int N = 3e5+5;
int n, d;
int a[N], dp[N];
void input() {
cin >> n >> d;
for (int i = 0; i < n; i++)
cin >> a[i];
}
void solve1() {
int ans = 0;
for (int i = n-1; i > -1; i--) {
int t = 0;
for (int j = i+1; j < n; j++) {
if (a[j] <= a[i]) {
t = 0;
continue;
}
t++;
dp[i] = max(dp[i], dp[j]);
if (t == d)
break;
}
dp[i]++;
ans = max(ans, dp[i]);
}
cout << ans << endl;
}
void solve2() {
}
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
input();
solve1();
}
# | 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... |