# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
846946 | SUNWOOOOOOOO | Financial Report (JOI21_financial) | C++17 | 0 ms | 0 KiB |
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>
using namespace std;
const int mxN = 7005;
int n, d, A[mxN], dp1[mxN][mxN], dp2[mxN][mxN]; // len, dist
vector <int> va;
int main()
{
memset(dp1, -1, sizeof dp1);
scanf("%d %d", &n, &d);
for (int i = 1; i <= n; i++) {
scanf("%d", &A[i]);
va.push_back(A[i]);
}
sort(va.begin(), va.end());
va.erase(unique(va.begin(), va.end()), va.end());
for (int i = 1; i <= n; i++) A[i] = lower_bound(va.begin(), va.end(), A[i]) - va.begin() + 1;
// int ans = 0;
// for (int i = 1; i <= n; i++){
// dp1[i][A[i]] = 1, dp2[i][A[i]] = 1;
// if (dp1[i - 1][A[i]] != -1 && dp2[i - 1][A[i]] <= d) dp1[i][A[i]] = dp1[i - 1][A[i]];
// for (int j = 1; j < A[i]; j++){
// if (dp1[i - 1][j] == -1 || dp2[i - 1][j] > d) continue;
// dp1[i][j] = dp1[i - 1][j];
// dp2[i][j] = dp2[i - 1][j] + 1;
// dp1[i][A[i]] = max(dp1[i][A[i]], dp1[i - 1][j] + 1);
// }
// for (int j = A[i] + 1; j <= n; j++){
// if (dp1[i - 1][j] == -1) continue;
// dp1[i][j] = dp1[i - 1][j];
// dp2[i][j] = 1;
// }
// for (int j = 1; j <= n; j++) ans = max(ans, dp1[i][j]);
// }
printf("%d\n", ans);
return 0;
}