Submission #737135

#TimeUsernameProblemLanguageResultExecution timeMemory
737135alexddFinancial Report (JOI21_financial)C++17
0 / 100
4058 ms2632 KiB
#include<bits/stdc++.h> using namespace std; int n,d; int a[300005]; int dp[300005]; signed main() { ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>d; for(int i=1;i<=n;i++) cin>>a[i]; int rez=0; for(int i=1;i<=n;i++) { int mxm=0,ult=i; for(int x=i-1;x>0;x--) { if(ult-x>d || dp[x]+1<=mxm) break; if(a[x]<a[i]) { mxm = max(mxm, dp[x]); ult = x; } else if(dp[x]<=mxm) break; } dp[i]=mxm+1; rez=max(rez,dp[i]); } cout<<rez; return 0; } /** dp[i] = scorul maxim care se poate obtine daca ultimul element care creste scorul se afla pe pozitia i dp[i] = max(dp[x]) + 1, a[x] < a[i], distanta dintre oricare 2 pozitii consecutive cu numere < a[i] este maxim d */
#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...