제출 #638903

#제출 시각아이디문제언어결과실행 시간메모리
638903SofiatpcFinancial Report (JOI21_financial)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define sc second const int MAXN = 405; int N,D; long long a[MAXN]; pair<int, long long> dp[MAXN][MAXN]; bool marc[MAXN]; pair<int, long long> fazdp(int i, int l)//qtd, mx { if(dp[i][l].fi!=-1)return dp[i][l]; if(l-i>D && l!=0)return dp[i][l]={0,0}; if(i==1)return dp[i][l]={1,a[1]}; int n = fazdp(i-1,l).fi; int s = fazdp(i-1,i).fi; if(fazdp(i-1,i).sc<a[i])s++; dp[i][l].fi=max(n,s); if(dp[i][l].fi==n)dp[i][l].sc=fazdp(i-1,l).sc; else dp[i][l].sc=max(fazdp(i-1,i).sc,a[i]); return dp[i][l]; } int main() { cin>>N>>D; for(int i = 1; i <= N; i++)cin>>a[i]; for(int i = 1; i <= N; i++) for(int l = 0; l <= N; l++)dp[i][l].fi=-1; cout<<max(fazdp(N,0).fi+1,1)<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...