# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
846965 | SUNWOOOOOOOO | Financial Report (JOI21_financial) | C++17 | 187 ms | 191728 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], dp[mxN], pass[mxN][mxN];
vector <int> va;
int main()
{
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;
for (int i = 1; i < n; i++){
for (int j = i + 1, last = i; j <= n; j++){
if (j - last <= d && A[i] < A[j]) pass[i][j] = 1;
if (j - last <= d && A[i] >= A[j]) last = j;
}
}
int ans = 0;
for (int i = 1; i <= n; i++){
dp[i] = 1;
for (int j = 1; j < i; j++){
if (!pass[j][i]) continue;
dp[i] = max(dp[i], dp[j] + 1);
}
ans = max(ans, dp[i]);
}
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
# | 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... |