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>
#include <fstream>
#define endl '\n'
#define mod 1000000007
#define INF 2000000000
#define INF2 1000000000000000000
///#define cin fin
///#define cout fout
using namespace std;
double const EPS = 1e-14;
typedef long long ll;
///ofstream fout("herding.out");
///ifstream fin("herding.in");
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, d; cin >> n >> d; int arr[n]; int dp[n]; int ans = 0;
for(int i = 0; i < n; i++) cin >> arr[i];
for(int i = 0; i < n; i++) {
dp[i] = 1;
for(int j = 1; j <= d; j++) {
if(i-j < 0) break;
if(arr[i-j] < arr[i]) {
dp[i] = max(dp[i],dp[i-j]+1);
}
}
ans = max(dp[i],ans);
}
cout << ans << endl;
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... |