# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
600434 | Plurm | Financial Report (JOI21_financial) | C++11 | 4061 ms | 121932 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;
int a[300005];
int dp[7005][7005]; // dp[last][max]
int main(){
int n, d;
scanf("%d%d",&n,&d);
for(int i = 1; i <= n; i++){
scanf("%d", a+i);
}
if(n > 7000){
vector<int> lis;
for(int i = 1; i <= n; i++){
auto it = lower_bound(lis.begin(), lis.end(), a[i]);
if(it == lis.end()) lis.push_back(a[i]);
else *it = a[i];
}
printf("%d\n", lis.size());
return 0;
}
for(int i = 1; i <= n; i++){
for(int j = 1; j < i; j++){
if(a[j] < a[i]) continue;
// dp[i][j] <- dp[k][j]
for(int k = i-1; k >= i-d && k > 0; k--){
if(a[j] < a[k]) continue;
dp[i][j] = max(dp[i][j], dp[k][j]);
}
}
// dp[i][i]
dp[i][i] = 1;
for(int k = i-1; k >= i-d && k > 0; k--){
for(int j = 0; j <= k; j++){
if(a[j] >= a[i]) continue;
dp[i][i] = max(dp[i][i], dp[k][j] + 1);
}
}
}
int ans = 0;
for(int j = 0; j <= n; j++) ans = max(ans, dp[n][j]);
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... |