# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
515720 | goodluck2020 | Financial Report (JOI21_financial) | C++14 | 173 ms | 984 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>
#define task "JOI21_FINANCIAL"
using namespace std;
const int N = 405;
int n, A[N], D, dp[N][N], ans;
set < int > Set;
int CP[N], cnt;
void compress()
{
for(int i = 1; i <= n; i++) Set.insert(A[i]);
for(int j : Set) CP[++cnt] = j;
for(int i = 1; i <= n; i++)
A[i] = lower_bound(CP + 1, CP + cnt + 1, A[i]) - CP;
}
int main()
{
if(fopen(task ".inp","r"))
{
freopen(task ".inp","r",stdin);
freopen(task ".out","w",stdout);
}
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> D;
for(int i = 1; i <= n; i++) cin >> A[i];
compress();
for(int i = 0; i <= n; i++)
for(int j = 0; j <= n; j++) dp[i][j] = -1e9;
dp[0][0] = 0;
for(int i = 0; i < n; i++)
{
if(i)
dp[i][A[i]] = max(dp[i][A[i]], 1);
for(int j = 0; j <= n; j++)
for(int t = i + 1; t <= i + D; t++)
if(t <= n)
dp[t][max(A[t], j)] = max(dp[t][max(A[t], j)], dp[i][j] + (A[t] > j));
}
for(int j = 0; j <= n; j++) ans = max(ans, dp[n][j]);
cout << ans;
}
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... |