Submission #617458

#TimeUsernameProblemLanguageResultExecution timeMemory
617458Abrar_Al_SamitFinancial Report (JOI21_financial)C++17
48 / 100
292 ms600 KiB
#include<bits/stdc++.h> using namespace std; const int MX = 7005; int dp[MX]; int n, D; int a[MX]; int solve(int i) { if(i==n) { return 1; } int &ret = dp[i]; if(ret!=-1) return ret; ret = 0; int last = i; for(int j=i+1; j-last<=D && j<=n; ++j) { if(a[j]<=a[i]) last = j; else { ret = max(ret, solve(j)); } } ++ret; return ret; } void PlayGround() { cin>>n>>D; for(int i=1; i<=n; ++i) { cin>>a[i]; } memset(dp, -1, sizeof dp); int ans = 0; for(int i=1; i<=n; ++i) { ans = max(ans, solve(i)); } cout<<ans<<'\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); PlayGround(); return 0; }
#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...