제출 #771149

#제출 시각아이디문제언어결과실행 시간메모리
771149gagik_2007Financial Report (JOI21_financial)C++17
48 / 100
151 ms3532 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; ll ttt; const ll INF=1e18; const ll MOD=1e9+7; const ll N=2e5+7; ll n,m,k; ll a[N]; ll dp[N]; int ri[N]; void precalc() { } int main() { precalc(); cin>>n>>k; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<n;i++){ ri[i]=i; for(int j=i+1;j<min(n,ri[i]+k+1);j++){ if(a[j]<=a[i]){ ri[i]=j; } } //cout<<ri[i]<<" "; } //cout<<endl; ll ans=0; for(int i=0;i<n;i++){ dp[i]=1; for(int j=0;j<i;j++){ if(a[i]>a[j]&&ri[j]>=i-k){ dp[i]=max(dp[i],dp[j]+1); } } if(ri[i]==n-1){ ans=max(ans,dp[i]); } //cout<<dp[i]<<" "; } cout<<ans<<endl; }
#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...