#include <bits/stdc++.h>
using namespace std;
int n, d, a[300005], memo[300005];
int dp(int i){
if(i == n) return 1;
if(memo[i] != -1) return memo[i];
memo[i] = 0; int l = i;
for(int j = i + 1; j - l <= d && j <= n; j++){
if(a[j] <= a[i]) l = j;
else memo[i] = max(memo[i], dp(j));
}
memo[i]++;
return memo[i];
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> n >> d;
for(int i = 1; i <= n; i++) cin >> a[i];
memset(memo, -1, sizeof(memo));
int ans = 0;
for(int i = 0; i <= n; i++) ans = max(ans, dp(i));
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4102 ms |
5688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4089 ms |
5972 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |