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 int long long
#define pb push_back
#define F first
#define S second
using namespace std;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
const int inf = 1e15;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,d;
cin >> n >> d;
vector<int>a(n + 1);
for(int i = 1; i <= n; i++) cin >> a[i];
vector<int>dp(n + 1);
for(int i = 1; i <= n; i++) {
dp[i] = max(dp[i],1ll);
int c = 0;
for(int j = i + 1; j <= n; j++) {
c++;
if(c > d) break;
if(a[j] > a[i]) dp[j] = max(dp[j],dp[i] + 1);
else c = 0;
}
}
int res = 0;
for(int i = 1; i <= n; i++) res = max(res,dp[i]);
cout << res;
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... |